开发者

How to remove all style attributes using jquery and also in PHP? [duplicate]

This question already has answers here: Closed 11 years ago.

Possible Duplicates:

php regexp: remove all attributes from an html tag

Remove style attribute from HTML tags

EDITED:

For example i am having the following content:

    <div style="text-indent: -76.5pt; margin: 0in 54.9pt 0pt 76.5pt;"><strong>Motion with Constant Acceleration</strong></div>

I need to remove all s开发者_开发问答tyle attributes using jQuery and PHP

My output should look like this:

    <div style=""><strong>Motion with Constant Acceleration</strong></div>

OR

    <div><strong>Motion with Constant Acceleration</strong></div>

How can this be done.. Any help will be thankful and grateful...

Thanks in advance...


jQuery option would be

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

PHP is referred in comments


Use not selector to exclude table

$("*[style]").not("table").removeAttr("style");

or

$("*[style]").not("table").attr("style", "");
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜