我想使用Jquery查找和替换标签属性或更改内联CSS。
例如 : <span style="text-decoration: underline;">
我想找到内联样式<span style="text-decoration: underline;">
并将其替换为<span class="line">
页面加载时的样式。
检查此DEMO:https : //jsfiddle.net/yv5apdaj/
您可以这样做,并根据需要更新css样式。
这样,您仍然可以使用其他样式并仅删除所需的CSS样式。
$(document).ready(function(){
$('span').each(function(){
if($(this).css('text-decoration') === 'underline'){
$(this).css({'text-decoration':''});
$(this).addClass('line');
}
});
});
<span style="text-decoration: underline;">Test Content</span><br /><br />
<span style="text-decoration: underline;">Test Content</span>
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句