我有一个选择框,在不同的元素中具有相同的类超级属性选择,例如
<dd class="clearfix swatch-attr" style="display: none;">
<div class="input-box">
<select name="super_attribute[327]" id="attribute327" class="required-entry super-attribute-select no-display swatch-select"
style="display: none;">
<option value="">Choose an Option...</option><option value="2178" price="0" data-label="not specified" selected="selected">Not Specified</option></select>
</div>
</dd>
<dd>
<div class="input-box field__input-wrapper">
<select name="super_attribute[481]" id="attribute481" class="required-entry super-attribute-select field__input field__input--select"
style="pointer-events: none;">
<option value="">Choose an Option...</option><option value="5531" price="0" data-label="intel core i5">Intel Core I5</option></select>
</div>
</dd>
<dd>
<div class="input-box field__input-wrapper">
<select name="super_attribute[500]" id="attribute500" class="required-entry super-attribute-select field__input field__input--select"
style="pointer-events: none;">
<option value="">Choose an Option...</option><option value="5828" price="0" data-label="8 gb ddr3">8 GB DDR3</option></select>
</div>
</dd>
<dd>
<div class="input-box field__input-wrapper validation-passed">
<select name="super_attribute[542]" id="attribute542" class="required-entry super-attribute-select field__input field__input--select validation-passed">
<option value="">Choose an Option...</option><option value="9396" price="424" data-label="3.3 ghz">3.3 GHz</option><option value="9393" price="300" data-label="3.2 ghz">3.2 GHz -BHD 124.00</option><option value="9628" price="84" data-label="3.1 ghz">3.1 GHz -BHD 340.00</option><option value="9626" price="0" data-label="2.8 ghz">2.8 GHz -BHD 424.00</option></select>
</div>
</dd>
<dd style="display: block;">
<div class="input-box field__input-wrapper">
<select name="super_attribute[543]" id="attribute543" class="required-entry super-attribute-select field__input field__input--select"
style="pointer-events: none; display: block;">
<option value="">Choose an Option...</option><option value="9857" price="0" data-label="amd radeon r9 290x">AMD Radeon R9 290X</option></select>
</div>
</dd>
<dd class="last">
<div class="input-box field__input-wrapper">
<select name="super_attribute[629]" id="attribute629" class="required-entry super-attribute-select field__input field__input--select"
style="pointer-events: none;" disabled="">
<option value="">Choose an Option...</option><option value="13288" price="0" data-label="1 tb">1 TB</option></select>
</div>
</dd>
我有js函数触发更改选择值
jQuery('.super-attribute-select').on('change', function () {jQuery('.super-attribute-select').each(function () {}}
我正在使用 .each 在任何选择值更改时迭代这些选择框。
但是我想只迭代那些选择框,这是在此更改后选择而不是从开始到结束的所有选择。就像我改变第三个选择框循环迭代必须从第三个开始而不是从第一个开始。我已经尝试了.nextAll()
但它只迭代兄弟姐妹它在我的情况下不起作用。
答案 0 :(得分:3)
你可以这样做
jQuery(this).closest('dd').nextAll('dd').find('.super-attribute-select');