我在 html 中有以下代码:
<p id='foo' style='text-align:center; font-size:14pt; font-family:verdana; color:red'>hello world</p>
在我的外部 CSS 里:
#foo{ font-size:11pt; font-family:arial; color:#000; }
我想删除所有的 font-size和 font-family在 style属性,但不是 color和其他设置在外部 css。
预期结果:
<p id='foo' style='text-align:center; color:red'>hello world</p>
已经试过了:
$('#foo').removeAttr('style'); // That removes all inline
$('#foo').css('font-family',''); // That remove the css setted too