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

后端 未结 2 815
刺人心
刺人心 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:35

    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);
    

提交回复
热议问题