Most of you are familiar with java.awt.Color constructor which takes the RGB values to create its instance, but java.awt.Color class also allows one to create its instances using hex color codes through very less known static method ‘ Color.decode(String) ’. Color obj = Color.decode("#006699"); Very simple isn’t it.
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&