2

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 :)

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.