到目前为止我得到了什么:JSFIDDLE
我想要的是:
<select>
如果未在其行中选择它,则添加类“无效”- 如果选择了该行中的 3 个选择,则删除此类
- 如果
<select>
选择了一行中的所有 s 然后提交表单 - 如果只
<select>
选择了一个,则将“无效”类添加到同一行中的其他 2 个选择中
这是 HTML,js 包含在上面的小提琴链接中:
<form id="productOptions" name="product-options">
<div class="selects s1">
<select name="selectss1" id="size1" class="product-select-options-size">
<option>-Size</option>
<option>Small</option>
<option>Medium</option>
<option>Large</option>
<option>X-large</option>
</select>
<select name="selectsc1" id="color1" class="product-select-options-color">
<option>-Color</option>
<option>Green</option>
<option>Pink</option>
<option>White</option>
<option>Yellow</option>
</select>
<select name="selectsq1" id="qty1" class="product-select-options-qty">
<option>-QTY</option>
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
</select>
</div>
<div class="selects s2">
<select name="selectss2" id="size2" class="product-select-options-size">
<option>-Size</option>
<option>Small</option>
<option>Medium</option>
<option>Large</option>
<option>X-large</option>
</select>
<select name="selectsc2" id="color2" class="product-select-options-color">
<option>-Color</option>
<option>Green</option>
<option>Pink</option>
<option>White</option>
<option>Yellow</option>
</select>
<select name="selectsq2" id="qty2" class="product-select-options-qty">
<option>-QTY</option>
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
</select>
</div>
<div class="selects s3">
<select name="selectss3" id="size3" class="product-select-options-size">
<option>-Size</option>
<option>Small</option>
<option>Medium</option>
<option>Large</option>
<option>X-large</option>
</select>
<select name="selectsc3" id="color3" class="product-select-options-color">
<option>-Color</option>
<option>Green</option>
<option>Pink</option>
<option>White</option>
<option>Yellow</option>
</select>
<select name="selectsq3" id="qty3" class="product-select-options-qty">
<option>-QTY</option>
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
</select>
</div>
<p><a href="#" class="add-more">+ Add more at one time</a></p>
<!-- End select options -->
<input type="image" name="product-options" src="/media/blackheart/images/blackheart/add-to-cart.png" />
</form>
好心提醒