Alex Rivera | Logout

How to get the text node of an element?

Asked 2011-06-29T11:52:15.433
135
<div class="title">
   I am text node
   <a class="edit">Edit</a>
</div>

I wish to get the "I am text node", do not wish to remove the "edit" tag, and need a cross browser solution.

Edit
Report

1 Answer

69

You can get the nodeValue of the first childNode using

$('.title')[0].childNodes[0].nodeValue

http://jsfiddle.net/TU4FB/

answered 2011-06-29T11:58:31.840

Your Answer