例如,如果您選擇id="chocolate-yes"
或id="vanilla-yes"
的選項,則也會選擇帶有id="icecreamcone-yes"
的選項。選擇一個選項將選擇其他選項
任何人都知道的Javascript可以做到這一點?
注1:id="sprinkles-yes"
選項不會影響id="icecreamcone-yes"
。
注2:id名稱不能更改,也不能爲元素添加更多屬性。
注3:不能使用jQuery。
<ul id="icecream" style="list-style:none;line-height:30px;">
<li>
<select id="icecreamcone">
<option value="addicecreamcone">Would you like an ice cream cone?</option>
<option id="icecreamcone-yes" value="yes">Yes</option>
<option id="icecreamcone-no" value="no">No thanks</option>
</select>
</li>
<li>
<select id="vanilla">
<option value="addvanilla">Would you like to add vanilla ice cream?</option>
<option id="vanilla-yes" value="yes">Yes</option>
<option id="vanilla-no" value="no">No thanks</option>
</select>
</li>
<li>
<select id="chocolate">
<option value="addchocolate">Would you like to add chocolate ice cream?</option>
<option id="chocolate-yes" value="yes">Yes</option>
<option id="chocolate-no" value="no">No thanks</option>
</select>
</li>
<li>
<select id="sprinkles">
<option value="addsprinkles">Would you like to add sprinkles on top?</option>
<option id="sprinkles-yes" value="yes">Yes</option>
<option id="sprinkles-no" value="no">No thanks</option>
</select>
</li>
</ul>
正在做作業嗎? (*由於許多限制* *) –