Get an array of list element contents in jQuery

后端 未结 6 1356
日久生厌
日久生厌 2020-11-27 11:33

I have a structure like this:

  • text1
  • text2
  • text3

6条回答
  •  悲哀的现实
    2020-11-27 11:52

    And in clean javascript:

    var texts = [], lis = document.getElementsByTagName("li");
    for(var i=0, im=lis.length; im>i; i++)
      texts.push(lis[i].firstChild.nodeValue);
    
    alert(texts);
    

提交回复
热议问题