可能的重复:
jquery - 获取没有子文本的元素的文本 https://stackoverflow.com/questions/11362085/jquery-get-text-for-element-without-children-text
我有一个 div,里面有文本,文本后面有跨度,如下所示:
<div>
text
<span>other text</span>
</div>
我只想获取 div 中的文本而不是 span 中的文本
Thanks
Try this
var myText = $('#dd').clone()
.children() //select all the children
.remove() //remove all the children
.end() //again go back to selected element
.text(); //get the text of element
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)