how to load css rules using javascript?

110

New Member
I am currently working with Vert.x. I can easily load the js files needed but when it comes to CSS, nothing loads EVER. So i guess my last resort is to write up some js to set these css rules(super last resort is to write the css INSIDE the html file).Is there a nice way to do this?I was thinking something like:\[code\]function loadIndexCss(){ document.getElementById("p2").style.color="blue"; document.getElementById("p2").style.fontFamily="Arial"; document.getElementById("p2").style.fontSize="larger";}\[/code\]save that in a file, then:\[code\]<script type="text/javascript" src="http://stackoverflow.com/questions/css/css.js"></script><body onload="loadIndexCss()"> <form id='frm_login'> <fieldset > <legend>Admin Login</legend> <label for='u' >Username: </label> <input type='text' name='username' id='u' maxlength="25" class="blocky"/> <label for='p' >Password: </label> <input type='password' name='password' id='p' maxlength="25" class="blocky"/> <br/> <input type='button' name='Login' value='http://stackoverflow.com/questions/14615335/Login' id="btn_login" /> </fieldset> </form></body>\[/code\]will that even work? if this is stupid, please teach :)
 
Back
Top