jquery exclude some child nodes from .text()

前端 未结 4 1091
醉话见心
醉话见心 2020-12-18 22:19

The html structure looks like this

parent may contain text
child 1 may contain text
4条回答
  •  悲&欢浪女
    2020-12-18 22:56

    This works for me and seems very generic [EDITED to make the procedure clearer]

    var t = [];
    $("#parent").each(function(i,e) 
        {if (e.nodeName!="SCRIPT") t.push(e.innerText);}​);​​​​​​​​​​​​​​
    console.log(t);
    

    Instead of console.log() you should obviously collect the strings in some other way (array?) to use them in your code.

    http://jsfiddle.net/8eu4W/3/

提交回复
热议问题