简体   繁体   中英

edit existing inline style using jquery?

I have some html which seems to default to :

<ul style="top: 72px; visibility: hidden;">

But i need Jquery to rescue me and change top: 72px to top: 37px

Is this possible? as in Firefox 37px seems to show up but in IE7 it shows up as 72px

Thanks

edit: added more info

the ul id = treemenu1

and its parent element is div class = treemenu

$('#treemenu1').css({ top: 37 });

Should work fine.

jsFiddle of POC.

I would select your ul by id:

$("#treemenu1").css("top", "37px");

Also note that you can update multiple css properties at once by passing an object in, whose keys and values correspond to css properties, and their new values:

$("#treemenu1").css({ "top": "37px", "bottom": "20px" });
$("ul").css("top", "37px");//this should work in all browsers.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM