我发现如何使用 jQuery 选择文本节点?但我的问题是,虽然我可以去
$(elem)
.contents()
.filter(function() {
return this.nodeType == Node.TEXT_NODE;
}).each(function() {
this.nodeValue = //stuff
});
我试图弄清楚如何this.nodeType
与before
andafter
节点结合,因为我需要的一些东西this.nodeValue + before
可以this.nodeValue
显示this.nodeValue + after
为上一个和下一个?