<select id="menu1">
<option data-icon="arrow-u" data-iconpos="top">- SELECT -</option>
<option data-icon="arrow-u" data-iconpos="bottom" selected="selected">Shrubs</option>
<option data-icon="arrow-u" data-iconpos="left">Trees</option>
<option data-icon="arrow-u" data-iconpos="right">Bushes</option>
</select>
<select id="menu2">
<option data-icon="arrow-u" data-iconpos="top">- SELECT -</option>
<option data-icon="arrow-u" data-iconpos="bottom" selected="selected">Shrubs</option>
<option data-icon="arrow-u" data-iconpos="left">Trees</option>
<option data-icon="arrow-u" data-iconpos="right">Bushes</option>
</select>
$('select').change(function () {
if ($(this).is('#menu1')) {
alert('menu hone has been changed')
}
})
以上说明了两个菜单和一个条件:如果选择了菜单一,则发出警报。我的代码中实际上有五个菜单,所以我需要精简。
需要将条件替换为将变量分配给已更改菜单的 id 的行。怎么做?