Select multiple 屬性
Select 對(duì)象定義和用法
multiple 屬性可設(shè)置或返回是否可有多個(gè)選項(xiàng)被選中。
語(yǔ)法
設(shè)置 multiple 屬性:
selectObject.multiple=true|false
返回 multiple 屬性:
selectObject.multiple
瀏覽器支持
所有主要瀏覽器都支持 multiple 屬性
實(shí)例
實(shí)例
在下拉選項(xiàng)中選取多個(gè)選項(xiàng):
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>W3Cschool在線教程(w3cschool.cn)</title>
<script>
function displayResult(){
document.getElementById("mySelect").multiple=true;
}
</script>
</head>
<body>
<form>
<select id="mySelect" size="4">
<option>Apple</option>
<option>Pear</option>
<option>Banana</option>
<option>Orange</option>
</select>
</form>
<button type="button" onclick="displayResult()">允許多個(gè)選擇</button>
<p>按下Ctrl鍵來(lái)選擇多個(gè)選項(xiàng)</p>
</body>
</html>
<html>
<head>
<meta charset="utf-8">
<title>W3Cschool在線教程(w3cschool.cn)</title>
<script>
function displayResult(){
document.getElementById("mySelect").multiple=true;
}
</script>
</head>
<body>
<form>
<select id="mySelect" size="4">
<option>Apple</option>
<option>Pear</option>
<option>Banana</option>
<option>Orange</option>
</select>
</form>
<button type="button" onclick="displayResult()">允許多個(gè)選擇</button>
<p>按下Ctrl鍵來(lái)選擇多個(gè)選項(xiàng)</p>
</body>
</html>
嘗試一下 ?
Select 對(duì)象
更多建議: