It\'s easy to set inline CSS values with javascript. If I want to change the width and I have html like this:
<
Please! Just ask w3 (http://www.quirksmode.org/dom/w3c_css.html)! Or actually, it took me five hours... but here it is!
function css(selector, property, value) {
for (var i=0; i
The function is really easy to use.. example:
Click Me!
Or:
Mouseover Me!
Or:
Click Me!
Oh..
(function (scope) {
// Create a new stylesheet in the bottom
// of , where the css rules will go
var style = document.createElement('style');
document.head.appendChild(style);
var stylesheet = style.sheet;
scope.css = function (selector, property, value) {
// Append the rule (Major browsers)
try { stylesheet.insertRule(selector+' {'+property+':'+value+'}', stylesheet.cssRules.length);
} catch(err) {try { stylesheet.addRule(selector, property+':'+value); // (pre IE9)
} catch(err) {console.log("Couldn't add style");}} // (alien browsers)
}
})(window);