Why doesn't $.each() iterate through every item?

后端 未结 3 1253
有刺的猬
有刺的猬 2020-12-09 01:24

I have the following markup containing 10 pre elements with the class indent:




        
3条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-09 01:54

    You are iterating through the string, you should pass an object or an array to $.each method:

    $(function(){    
        $.each($(".indent"), function(index){
           alert(index);
        });    
    });
    

提交回复
热议问题