简体   繁体   中英

jquery to set multiple css properties of a same class with important

I need to set multiple css properties using jquery to a same class with important key word for all the properties. My attempt is as below.

$(".k-window").css({
 'bottom' : '0% !important',
 'position' : 'fixed !important'
});

But above way not worked. I know if we need to add for one attribute with important we can use below.

$(".k-window").css("cssText", "bottom: 0% !important;");

But what happens if we need to set it for multiple attributes with important for each? Anyone knows how to achieve it?

So if you need to set multiple css properties using jquery to a same class with important key word for all the properties if you have 1 or more styles to change you can make it like that:

.css({
   'font-size' : '10px',
   'width' : '30px',
   'height' : '10px'
});

and use addClass()

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