<div>
<span>
<span style="font-weight: bold;">MyName</span>
</span>
</div>
我如何能够删除 MyName 周围的跨度但保留初始跨度?
谢谢
<div>
<span>
<span style="font-weight: bold;">MyName</span>
</span>
</div>
我如何能够删除 MyName 周围的跨度但保留初始跨度?
谢谢
将.unwrap()与.contents()结合使用:
$('#innerspan').contents().unwrap();
标记:
<span>
<span id="innerspan" style="font-weight: bold;">MyName</span>
</span>
将字符串转为元素,获取 span 的 HTML 内容:
s = $(s).html();
You can do next this time:
$('span').each(function() {
if ($(this).html() == "MyName") {
$(this).parent().html("MyName");
}
});
But it's very localized code.