Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/sql-server-2005/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用jquery和PHP删除所有样式属性?_Php_Jquery_Html - Fatal编程技术网

如何使用jquery和PHP删除所有样式属性?

如何使用jquery和PHP删除所有样式属性?,php,jquery,html,Php,Jquery,Html,可能的重复项: 编辑: 例如,我有以下内容: <div style="text-indent: -76.5pt; margin: 0in 54.9pt 0pt 76.5pt;"><strong>Motion with Constant Acceleration</strong></div> 恒定加速度运动 我需要使用jQuery和PHP删除所有样式属性 我的输出应该如下所示: <div style=""><

可能的重复项:

编辑:

例如,我有以下内容:

    <div style="text-indent: -76.5pt; margin: 0in 54.9pt 0pt 76.5pt;"><strong>Motion with Constant Acceleration</strong></div>
恒定加速度运动
我需要使用jQuery和PHP删除所有样式属性

我的输出应该如下所示:

    <div style=""><strong>Motion with Constant Acceleration</strong></div>
恒定加速度运动

    <div><strong>Motion with Constant Acceleration</strong></div>
恒定加速度运动
怎样才能做到这一点。。任何帮助都将是感激和感激的

提前感谢…

jQuery选项将是

$('*[style]').attr('style', ''); 
// sets style attribute to empty string on all elements that have it
PHP是在注释中引用的,jQuery选项是

$('*[style]').attr('style', ''); 
// sets style attribute to empty string on all elements that have it

注释中引用了PHP,请使用not选择器排除表

$("*[style]").not("table").removeAttr("style"); $(“*[样式]”)。不是(“表格”)。删除属性(“样式”); 或

$(“*[style]”。不是(“表”).attr(“style”,”);
使用not选择器排除表

$("*[style]").not("table").removeAttr("style"); $(“*[样式]”)。不是(“表格”)。删除属性(“样式”); 或

$(“*[style]”。不是(“表”).attr(“style”,”);
红色药丸或蓝色药丸(jQuery或PHP)由您选择。这取决于您是否希望在PHP或jQuery中执行此操作。在PHP中,您可以使用preg_replace删除style属性。。。在jQuery中,您可以使用.removeAttr(“样式”);我需要知道如何使用这两种方法。。。有人能解释一下吗?红色药丸或蓝色药丸(jQuery或PHP)由你选择。这取决于你是想用PHP还是jQuery。在PHP中,您可以使用preg_replace删除style属性。。。在jQuery中,您可以使用.removeAttr(“样式”);我需要知道如何使用这两种方法。。。请任何人解释一下……即使你的版本完全有效,我认为在选择器中使用否定会使它更简洁易懂。例如,
$(“*[样式]:非(表)”).removeAttr(“样式”)即使您的版本是完全有效的,我认为在选择器中使用否定可以使其更加简洁和易于理解。例如,
$(“*[样式]:非(表)”).removeAttr(“样式”)