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