How to get second word

javascript, jquery, jquery-selectors

Solution

You can use jQuery contents() along with eq():

var second = $('.test').contents().filter(function() {
                 return this.nodeType == Node.TEXT_NODE;
             }).eq(1).text(); 

Working Demo

Problem

I have following HTML: ``` <div class="test"> First <p></p> Second <p></p> Third </div> ``` How can I get the word `Second` in this case?

Original source