我想要不同的行为,具体取决于<option>
选择的元素:
<select name="colorSelector" onchange="handleColorChange();">
<option value="">- select -</option>
<option value="1">Red</option>
<option value="2">Blue</option>
</select>
function handleColorChange() {
// Behave different depending on which <option> was just selected
}
为了实现这一点,我需要handleColorChange()
从侦听器内部传递什么到方法中?onchange