的文字我已经在HTML如何获得股利
<div>abc, deef, aas,a, <span>this is span</span></div>
如何获得唯一的div元素不跨越它包含的文本下面。 例如abc,deef,aas,a,
我编写下面的代码,但它返回其本身及其子元素内的所有文本。
var text = $("div").text()
的文字我已经在HTML如何获得股利
<div>abc, deef, aas,a, <span>this is span</span></div>
如何获得唯一的div元素不跨越它包含的文本下面。 例如abc,deef,aas,a,
我编写下面的代码,但它返回其本身及其子元素内的所有文本。
var text = $("div").text()
var txt = $('div').text().replace($('div span').text(),"");
尝试过滤内容
var text = $('div').contents().filter(function() {
return this.nodeType == 3;
}).text()
http://api.jquery.com/contents/
编辑:妈的,打它:(
感谢buddy它的工作 –