text() , as you discovered, receives the text not only of the target node (s), but also of any child / stream nodes.
Even if it weren’t, your code in its current form would still return the concatenation of both parts of the text, because your selector is just a div , so jQuery will search for all div and get their text as one piece of text.
You can get the immediate text of an element with just something similar, although there are other ways.
//make a mini plugin for getting the immediate text of an element $.fn.extend({ immediateText: function() { return this.clone().find("*").remove().end().text(); } }); //use the plugin var immediateText = $('#some_element').immediateText();
source share