更新时间:2023-11-27 09:02:28
是否可以向div中的每个select添加一个类?像这样:
Can you add a class to each of the selects in the div? Like so:
<div id="cat1">
<select id="sel1" class="div1">
<option value="abc" > abc </option>
<option value="def" > def </option>
</select>
<select id="sel2" class="div1">
<option value="rst" > rst </option>
<option value="uvw" > uvw </option>
</select>
</div>
然后jQuery可以做到这一点:
Then the jQuery could do this:
$('.div1').each(function() {
alert ('hi'); // does not even iterate
alert($(this).val());
});