Bre*_*ett 16 javascript each jquery
我正在尝试使用jQuery循环遍历具有相同类名的元素列表并提取其值.
我有这个..
function calculate() {
// Fix jQuery conflicts
jQuery.noConflict();
jQuery(document).ready(function(){
// Get all items with the calculate className
var items = jQuery('.calculate');
});
}
Run Code Online (Sandbox Code Playgroud)
我正在阅读each()函数,虽然在这个例子中弄错了如何正确使用它.
Dar*_*rov 49
jQuery('.calculate').each(function() {
var currentElement = $(this);
var value = currentElement.val(); // if it is an input/select/textarea field
// TODO: do something with the value
});
Run Code Online (Sandbox Code Playgroud)
如果你想在集合中获得它的索引:
jQuery('.calculate').each(function(index, currentElement) {
...
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
49074 次 |
| 最近记录: |