改用onchange事件
<select name="history" id="history" onchange="historyChanged(this);">
<option value="history1">history 1</option>
<option value="history2">history 2</option>
<option value="clearhistory">Clear History</option>
</select>
function historyChanged() {
var historySelectList = $('select#history');var selectedValue = $('option:selected', historySelectList).val();
alert(selectedValue);
if (selectedValue == 'clearHistory') {
historySelectList.form.submit();
}
}
本文介绍了一种利用HTML的onchange事件来响应下拉菜单选择变化的方法,并通过一个具体的示例展示了如何使用JavaScript来实现清除历史记录的功能。当用户选择'ClearHistory'选项时,页面会提交表单以执行相应的操作。
1735

被折叠的 条评论
为什么被折叠?



