Jquery如何获取某个元素前(后)的文本内容?

<span>
text here...
<a id="target_element">百万创想</a>
</span>

如何获得a标签前面的"text here"处的文本内容呢?

$("#target_element").parent().contents().filter(function(){
return this.nodeType == 3;
}).text();

原文地址:https://www.cnblogs.com/suizhikuo/p/10278313.html