views:

33

answers:

1

hi! i have this html block:

<p><strong>this is the title</strong>this is the content</p>

how do i get only the "this is the content" string with jQuery?

thank you :)

+2  A: 

Try this: http://jsfiddle.net/mTn7G/

var text = $('p').contents().last().text();

The .contents() method gets all child elements, including text nodes, while .last() will give you the last one, and .text() will return its text content.

patrick dw
thank you very much for your help!
alon