如何循环所有ul标签并使用JQuery在它们上实现一个函数?

如何使用特定的类名循环所有
ul
标签并在其上实现一个功能? 我尝试了这个,但它没有用
$("ul.innerContainer").foreach(function(){
  //do something with the element
});
    
已邀请:
这是
each()
不是
foreach()
$("ul.innerContainer").each(function(){
  //do something with the element
});
    
差不多了:
$("ul.innerContainer").each(function(){
    // do something with '$(this)'
});
    
该方法称为
each
,而不是
foreach
。     
$('ul.innerContainer').each(function(index) {
   //function here
});
    

要回复问题请先登录注册