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

版权声明:UU小七 :转载请标注哦!^v^ https://blog.csdn.net/qq_36474549/article/details/84761055

参考博主:https://www.cnblogs.com/zjfblog/p/7641377.html

<span>
   获取的内容!
    <a id="test">哈哈哈哈哈</a>
</span>

获取方式:

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

猜你喜欢

转载自blog.csdn.net/qq_36474549/article/details/84761055