编辑:
例如,我有以下内容:
<div style="text-indent: -76.5pt; margin: 0in 54.9pt 0pt 76.5pt;"><strong>Motion with Constant Acceleration</strong></div>
Run Code Online (Sandbox Code Playgroud)
我需要使用jQuery和PHP 删除所有样式属性
我的输出应该如下所示:
<div style=""><strong>Motion with Constant Acceleration</strong></div>
Run Code Online (Sandbox Code Playgroud)
要么
<div><strong>Motion with Constant Acceleration</strong></div>
Run Code Online (Sandbox Code Playgroud)
怎么办呢......任何帮助都会感恩和感激......
提前致谢...
mki*_*nas 11
jQuery选项将是
$('*[style]').attr('style', '');
// sets style attribute to empty string on all elements that have it
Run Code Online (Sandbox Code Playgroud)
PHP在评论中被引用
使用not selector排除表
$("*[style]").not("table").removeAttr("style");
要么
$("*[style]").not("table").attr("style", "");