循环使用给定类名的元素

时间:2010-08-12 20:55:41

标签: jquery dom

使用jquery,我如何遍历给定类中的所有元素?

2 个答案:

答案 0 :(得分:3)

使用each方法。

$('.klass').each( function() {
    $(this)... // will be an instance of the element matching the class selector
});

答案 1 :(得分:2)

如有疑问,请查看文档:{​​{3}}