?? 10-6 控制下拉列表框.htm
字號(hào):
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=GB2312" />
<title>10-6 控制下拉列表框</title>
<script>
//向下拉列表框中添加新項(xiàng)目
function add_to_select(){
var op = new Option(); //建立一個(gè)新項(xiàng)目
op.innerHTML = (new Date()).toLocaleString(); //新項(xiàng)目的內(nèi)容為當(dāng)前日期時(shí)間
select1.appendChild(op); //將新項(xiàng)目加入下拉列表框
}
//從下拉列表框中刪除當(dāng)前項(xiàng)目
function del_select(){
if(select1.options.length<1)return; //如果下拉列表框中沒(méi)有項(xiàng)目,則取消操作
var op = select1.options[select1.selectedIndex]; //取得當(dāng)前項(xiàng)目
select1.removeChild(op); //刪除當(dāng)前項(xiàng)目
}
function select_next(){
//如果下拉列表框中沒(méi)有項(xiàng)目或當(dāng)前項(xiàng)目已是最后一個(gè),則取消操作
if(select1.options.length<1 || select1.selectedIndex > select1.options.length-2)return;
select1.options[select1.selectedIndex+1].selected = true; //選中下一個(gè)項(xiàng)目
}
</script>
</head>
<body style="overflow:auto;">
<select id="select1"></select><br/>
<input type="button" onclick="add_to_select();" value="添加項(xiàng)目"><br/>
<input type="button" onclick="del_select();" value="刪除項(xiàng)目"><br/>
<input type="button" onclick="select_next();" value="選中下一個(gè)項(xiàng)目">
</body>
</html>
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -