insert element in the dom using javascript or jquery

前端 未结 2 1616
清歌不尽
清歌不尽 2021-01-14 21:34

I am using this script to insert three different span\'s to the 1st, 2nd and 3rd lis.

$(\"ul li:eq(0)\").prepend(\"1&l         


        
2条回答
  •  离开以前
    2021-01-14 22:15

    Or you can do this like this

      $("ul li").prepend( function(index, html){
                   return ("" + (index+1) + "");
       });
    

提交回复
热议问题