希望有人可以提供帮助。我需要抓取正文内的任何文本节点。即使它不包含在任何其他元素中。使用Jquery获取身体内的任何文本节点
我已经试过:
$("p, div, html, body").each(function(){
$(this).contents().filter(function() {
var regExText = /(\w|\d|,|;|&)/;
if (this.nodeType == 3 && regExText.test(this.nodeValue)) {
$(this).wrap('<span></span>');
}
});
});
这是抓住他们在PS和Div的,但不是身体本身。
这是正确答案? ;-) – netadictos 2010-10-19 07:56:33