Possible Duplicate:
jquery – get text for element without children text
I’ve a div with text inside and span after text like this:
<div>
text
<span>other text</span>
</div>
and I’d like to get only text in div not in span
Thanks
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can use .clone() for that, like so:
Using
.clone()we can make a copy of the div, remove the span, and then get the text, all without affecting the original DOM elements displayed on the page.