我是 jQuery 新手。
我的代码中有一个变量增量,它显示面板中有多少个 div。
我想迭代这些 div 来获取标签的属性、输入类型、每个 div 内所有内容的大小。
从 1 开始,我想迭代到增量..我怎样才能在 JQUery 中做到这一点?请给我一个建议。
最佳答案
如果您想遍历 JQuery 面板中的所有 div,那么最简单的方法就是执行以下操作:
$("#panel div").each(function() {
// $(this) refers to the div
}
如果您想将其限制为前 N 个 div,那么有多种方法可以做到这一点:
$("#panel div:lt(" + (N+1) + ")").each(function() {
// limits to the only those div's less than N+1.
}
关于jquery - JQuery 中的迭代,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1057226/