jQuery循环使用相同类的元素 [英] jQuery to loop through elements with the same class
本文介绍了jQuery循环使用相同类的元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个带有证词
类的div加载,我想使用jquery循环遍历它们以检查每个div是否为特定条件为真。如果是真的,它应该执行一个动作。
I have a load of divs with the class testimonial
and I want to use jquery to loop through them to check for each div if a specific condition is true. If it is true, it should perform an action.
有谁知道我会怎么做?
推荐答案
使用每个:' i
'是数组中的位置, obj
是您正在迭代的DOM对象(可以通过jQuery包装器 $(this)
访问)。
Use each: 'i
' is the postion in the array, obj
is the DOM object that you are iterating (can be accessed through the jQuery wrapper $(this)
as well).
$('.testimonial').each(function(i, obj) {
//test
});
检查 api参考以获取更多信息。
这篇关于jQuery循环使用相同类的元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文