Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing stylesheets after DOM is loaded [duplicate]

In my HTML I have a div:

<div id="devicelayout">
    Some text here
</div>

and corresponding CSS:

#devicelayout
{
    width:1078px;
}

Once my page is loaded, how do I change the rules of CSS #devicelayout?

like image 632
user3499814 Avatar asked Aug 31 '25 20:08

user3499814


1 Answers

If you just want to change css styles of the element you can directly assign a different class to it or change css properties of the element using JQuery using

$("#devicelayout").css("property", "value")

or

$("#devicelayout").addClass("newClass")

Or if you want to change css rules then try modifying stylesheet rules at document.styleSheets object. See here

like image 152
KKK Avatar answered Sep 03 '25 10:09

KKK