option觸發事件
阿新 • • 發佈:2019-02-16
option本身是沒有觸發事件的,需要藉助於select的onchange事件來實現。
不多說,直接上程式碼:
<select id="status_select" onchange="optionChange()"> <option grade="1" value="option0">按狀態顯示</option> <option grade="2" value="已結束">已結束</option> <option grade="3" value="進行中">進行中</option> <option grade="4" value="未開始">未開始</option> </select>
<script type="text/javascript">
function optionChange(){
var select = document.getElementById("status_select");
var grade = select.value;
//alert(grade);
var url = "edudetail_statusSelect.action?grade=" + grade;
window.location.href=url;
}
</script>