Get the text after span element using jquery
Get the text after span element using jquery
<div id="mydiv">
<div>
<span>Text inside span</span>
Text next to span
</div>
<div>
Contents inside the 2nd div element...
</div>
</div>
如果想取得上面html代码中的”Text next to span”,使用下面的方法即可:
var a = $('#mydiv div').first().contents().filter(function(){
returnthis.nodeType ==3;
}).text();