简体   繁体   English

jquery 设置同一个 class 的多个 css 属性具有重要

[英]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.我需要使用 jquery 将多个 css 属性设置为具有所有属性的重要关键字的相同 class 。 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: 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()并使用 addClass()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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