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

如何避免使用jquery或javascript查找css属性,javascript,jquery,Javascript,Jquery,html页面中有一些内容,其中一个为div样式,如下所示: .class1{ property1:value1; property2:value2; property3:value3; property4:value4; } 我希望避免将css属性property1应用到相关内容中,并且欢迎使用rest属性property2、property3、property4 我想避免应用property1,也不想更改css文件 此外,我不想使用以下内容: $('.class1').css('proper

html页面中有一些内容,其中一个为div样式,如下所示:

.class1{
property1:value1;
property2:value2;
property3:value3;
property4:value4;
}
我希望避免将css属性property1应用到相关内容中,并且欢迎使用rest属性property2、property3、property4

我想避免应用property1,也不想更改css文件

此外,我不想使用以下内容:

$('.class1').css('property1','some different value');
 $('.ui-resizable').css('position').disable()
我只是想避免使用代码的属性1。 请告诉我如何使用jquery或js。 ----------------------编辑------------------------

我不想在运行时生成任何内联css。 我正在查看ui代码,如下所示:

$('.class1').css('property1','some different value');
 $('.ui-resizable').css('position').disable()

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

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

只需在元素上设置一个内联样式,以否定该属性或使其符合您的需要。不需要jQuery。内联样式将始终覆盖继承的样式

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

使用css创建另一个类“class2”,并使用

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

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

将财产1的价值保留为:

var p1 = $('.class1').css('property1');
$('.class1').css('property1',p1);
现在,根据需要对类应用更改

最后,将property1的值恢复为:

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

你为什么不想做那些事?如果你不能这样做,你能做什么?再次添加
.class1
,只添加
属性1
,但这次添加属性的默认值。我认为你需要在class1上指定内联样式,替换该值。我不想使用任何内联css!我能问一下为什么吗?内联CSS不是脏的或任何东西。这是完成某些任务的一种完全合法的方式。显然,您在这里尝试做的是一个黑客开始-为什么不创建一个没有该属性的新类呢?