的文字我已經在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它的工作 –