简体   繁体   English

如何避免使用jquery或javascript查找CSS属性

[英]how to avoid looking css property using jquery or javascript

There is some content in html page and one of div style for that is like below: html页面中有一些内容,其中一种div样式如下所示:

.class1{
property1:value1;
property2:value2;
property3:value3;
property4:value4;
}

I want to avoid applying css property property1 into concerned content and rest property property2, property3, property4 are welcomed. 我想避免将CSS属性property1应用于相关内容,并欢迎其余属性property2,property3,property4。

I want to avoid applying property1 and don't want to change the css file. 我想避免应用property1,并且不想更改css文件。

Also I don't want to use as below: 我也不想使用如下:

$('.class1').css('property1','some different value');

I just want to avoid property1 using code. 我只是想避免使用代码的property1。 Please tell me how I done using jquery or js. 请告诉我如何使用jquery或js。 ----------------------Edited------------------------ ----------------------编辑------------------------

I don't want to generate any inline css on run time. 我不想在运行时生成任何内联CSS。 I am looking ui code some thing like as below: 我正在寻找ui代码,如下所示:

 $('.ui-resizable').css('position').disable()

没有可用的功能可以做到这一点,一种方法是

$('.class1').css('property1',''); 

Just set an inline style on the element that negates the property or makes it what you want. 只需在元素上设置内联样式即可使该属性取反或使其成为您想要的。 No jQuery necessary. 无需jQuery。 Inline styles will always override inherited styles. 内联样式将始终覆盖继承的样式。

<div class="class1" style="margin:whatever"></div>

Make another class "class2" with css and use 使用CSS使另一个类“ class2”并使用

/* CSS */
.class2{
property1:value1;
}

//JQuery
$('div').removeClass('class1').addClass('class2');

Preserve the value of property1 as: 将property1的值保留为:

var p1 = $('.class1').css('property1');

Now apply changes to the class as necessary. 现在,根据需要将更改应用于类。

Finally, restore the value of property1 as: 最后,将property1的值恢复为:

$('.class1').css('property1',p1);

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

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