add styles element with value to head - Javascript jQuery

Javascript examples for jQuery:CSS

Description

add styles element with value to head

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript" src="https://code.jquery.com/jquery-1.7.1.js"></script> 
      <script type="text/javascript">
    $(function(){// w  ww. ja  va2  s  . c o m
$('<style>body { background-color: red; color: white; }</style>').appendTo('head');
    });

      </script> 
   </head> 
   <body>
       foo  
   </body>
</html>

Related Tutorials