remove all
  • from
      ?
  • 后端 未结 7 1009
    北荒
    北荒 2020-12-15 02:48

    I am appending li in a ul using the following code:

    for (var i = 1; i <= len; i++) {
        li = document.createElement(\'li\');
    
              
    
    
            
    7条回答
    •  -上瘾入骨i
      2020-12-15 03:33

      You need to fetch the elements before removing them as the native DOM methods (most of them anyway) can't be passed in selector strings the same way jQuery's methods can.

      var lis = root.getElementsByTagName("li");
      
      for(var i = 0, il = lis.length;i

    提交回复
    热议问题