But I need jQuery to save...">

Edit existing inline style using jquery?

I have html which defaults to:

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

But I need jQuery to save me and change the top: 72px at the top: 37px

Is it possible? as it appears in Firefox 37px, but in IE7 it appears as 72px

thanks

edit: more info added

ul id = treemenu1

and its parent element is div class = treemenu

+6
source share
3 answers
 $('#treemenu1').css({ top: 37 }); 

Should work fine.

jsFiddle POC.

+12
source

I would select your ul by id:

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

Also note that you can update several CSS properties at once by passing an object whose keys and values ​​correspond to the css properties and their new values:

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

Source: https://habr.com/ru/post/902944/


All Articles