Generally you might not need/want to do this, in fact you’ll rarely change elements of ‘head’ tag using Java script. But this is for those who are left with no other choice. It is really simple, JQuery provides a methods ‘ text() / html() ’ which will allow you to change content of any DOM element. To change the ‘Style’ tag content we can use ‘ text() ’ method, sample code is provided below. <html> <head> <style id="myStyles" type="text/css"> .header { color: blue; } </style> <script type="text/javascript"> $("#myButton").click(function(e) { $("#myStyles").text(".header { color: green }"); }); </script> </head> <body> <h2 class="header">My Page Heading</h2> <input type="button" id="myButton" value="Click Me...
A techie who love to read, code and share ...