Tuesday, July 24, 2012

css – javascript beginner: add a dynamic style in javascript?



I write a dynamic form using java-script. I want to add the style in java-script itself. I write some code to add a style. But it is not working.This is the code am write in my project.



var sheet = document.createElement(\'style\');
sheet.type=\"text/css\";
sheet.innerHTML = \"body{color:red;}\";
document.body.appendChild(sheet);


Anyone help me please.






Rating: 3 out of 5 based on 5 ratings



The post css – javascript beginner: add a dynamic style in javascript? appeared first on Javascript ASK.






via Javascript ASK http://javascriptask.phpfogapp.com/css-javascript-beginner-add-a-dynamic-style-in-javascript.html

No comments:

Post a Comment