var a = $('#mydiv div').first().contents().filter(function() {
return this.nodeType == 3;
}).text();
This gets the contents of the selected div
, and filters the matched set, returning only elements with nodeType == 3
, which are text nodes.