jQuery get .text() but not the text in span
Nice solution Herman, though it can be reduced to something like this:
JS
$('li a').contents().filter(function() {
return this.nodeType == 3;
}).text();
HTML
<li><a href="#">Apple<span>hi</span> Juice</a></li>
Will return Apple Juice
Fiddle: http://jsfiddle.net/49sHa/1/
Yes, you can select only the text contents of the element, like this:
var text = '';
$('a').contents().each(function(){
if(this.nodeType === 3){
text += this.wholeText;
}
});
$("#largemenutop").html(text);