Changing input name using JQUERY

后端 未结 2 1882
眼角桃花
眼角桃花 2021-02-05 17:26

I\'m trying to change all the input name based on the list index of

  • but it seems like it\'s not changing at all.

    $(\'.test\').click(funct         
    
    
            
  • 2条回答
    •  甜味超标
      2021-02-05 18:00

      You are cloning the object, so the change is done to a copy rather than the original DOM node.

      Don't use clone() and you'll be fine. Or do this:

      $("li.songs input").each(function(i) {
        $(this).attr('name', $(this).attr('name') + i);
      });
      

    提交回复
    热议问题