get text of element
<div id="mydiv">
<div>
<span>Text inside span</span>
Text next to span
</div>
<div>
Contents inside the 2nd div element...
</div>
</div>
I wanted to get the "Text next to span".
var a = $('#mydiv div').first().contents().filter(function() {
return this.nodeType == 3;
}).text();