jQuery get .text() but not the text in span

后端 未结 2 798
刺人心
刺人心 2020-12-31 11:41

Hi guys this is my jQuery part that makes my menu for my pages.

function fetchmenus() {
    $.getJSON(\'sys/classes/fetch.php?proccess=1\', function(status)          


        
2条回答
  •  离开以前
    2020-12-31 12:37

    Nice solution Herman, though it can be reduced to something like this:

    JS

    $('li a').contents().filter(function() {
        return this.nodeType == 3;
    }).text();
    

    HTML

  • Applehi Juice
  • Will return Apple Juice

    Fiddle: http://jsfiddle.net/49sHa/1/

提交回复
热议问题