如何使用jQuery删除html中的内联样式?(How to remove inline styling in html using jQuery?)

编程入门 行业动态 更新时间:2024-10-17 17:22:26
如何使用jQuery删除html中的内联样式?(How to remove inline styling in html using jQuery?)

是否可以使用jQuery删除应用于HTML的任何样式,而不是通过CSS或样式属性,例如:

<table width="100%" border="0" cellSpacing="0" cellPadding="0">

我想删除width,border,cellSpacing和cellPadding。

我在这里看过这篇文章: 使用jQuery删除内联样式但它只对特定属性执行此操作加上它似乎使用style属性应用它而不删除内联属性。

编辑:我不想删除使用style属性应用的任何内容我想要删除任何未使用它的任何内容谢谢

Is it possible using jQuery to remove any styles applied to an HTML not via CSS or the style attribute, for example here:

<table width="100%" border="0" cellSpacing="0" cellPadding="0">

I'd like to remove width, border, cellSpacing & cellPadding.

I've seen this post here: Use jQuery to remove an inline style but it only does that for a specific attribute plus it seems to apply it using the style attribute and not remove inline ones.

EDIT: I don't want to remove anything that has been applied using the style attribute I want to remove anything that hasn't been applied using it Thanks

最满意答案

以前的答案正好说明了你想要的东西。

不是通过CSS或style属性。 我想删除width,border,cellSpacing和cellPadding。

$('*').removeAttr('width border cellSpacing cellPadding'); // etc

Previous answers are stating exactly what you didn't want.

not via CSS or the style attribute. I'd like to remove width, border, cellSpacing & cellPadding.

$('*').removeAttr('width border cellSpacing cellPadding'); // etc

更多推荐

本文发布于:2023-07-26 00:27:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1268419.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:内联   如何使用   样式   jQuery   styling

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!