我想删除应用于特定div的内联和外部css。
我不想使用删除页面所有样式的remove_all_styles()。
我怎样才能做到这一点?
答案 0 :(得分:1)
删除样式和类属性是否可以解决问题?
$("#ParticularDiv").removeAttr("class").removeAttr("style");
答案 1 :(得分:1)
你可以试试;
$("#div"){
remove_attributes()
}
然后你会有一个空白的石板。
答案 2 :(得分:0)
删除特定div的内联css
$('#div_id').removeAttr('style');
或者您也可以使用not
属性在您的css中执行此操作。
在html中:
<button class="nostyle">
在css中:
button:not(.nostyle) {
答案 3 :(得分:0)
您可以通过使用氚选择div
,然后使用attribute(...)
功能清除style
属性来实现。说我有以下html:
<html>
<body>
<div style="background: red">Hi</div>
</body>
</html>
我可以编写以下氚来删除内联样式:
$("/html/body/div") {
attribute("style", "")
}
此快捷方式是在tritium中使用remove(...)
函数。使用一些XPath魔法,您可以将上面的代码转换为单行代码,如下所示:
remove("/html/body/div/@style")
这应该删除与div
相关联的内联样式。
答案 4 :(得分:0)
您可以通过$(&#39; #div&#39;){remove_atributes()}删除它,这将删除div中的所有属性,否则您可以使用remove_class(&#39; ClassName&#39;)将删除包含样式的类