我正在尝试从一组div上包含的三个输入中获取值,但只有不属于这些的ediv invisible-age-range-row<div class="row"> <div class="col-md-7 col-xs-12 dist-element-row"> <label>Franjas de edad</label> <div class="row age-range-row"> <div class="col-md-2"> <label>Desde</label> <input type="number" min="0" class="form-control from" value="1"> </div> <div class="col-md-2"> <label>Hasta</label> <input type="number" min="0" class="form-control to" value="2"> </div> <div class="col-md-2"> <label>%</label> <input type="number" min="0" max="100" class="form-control percentage" value="20"> </div> <div class="col-md-6 options-cell"> <button class="btn btn-primary add-range">+</button> <button class="btn btn-default delete-range">-</button> </div> 我这样得到的divvar ranges = $('.age-range-row').not('.invisible-age-range-row');但是我不能以这种方式访问输入值:ranges.each(function(range) { var elements = []; console.log(range); elements.push(range.find('.from')); elements.push(range.find('.to')); elements.push(range.find('.percentage')); stored_ranges.push(elements);});
3 回答
大话西游666
TA贡献1817条经验 获得超14个赞
每个函数的第一个参数指的是元素的索引。您需要使用range作为第二个元素才能用作元素选择器:
ranges.each(function(index,range){
var elements = [];
console.log(range);
elements.push(range.find('.from'));
elements.push(range.find('.to'));
elements.push(range.find('.percentage'));
stored_ranges.push(elements);
});
添加回答
举报
0/150
提交
取消