您的位置:首页 > Web前端 > JavaScript

JavaScript -- Select

2014-05-14 17:02 99 查看
-----053-Select.html-----

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>标题</title>
</head>
<body>
<h3>哪条最经典?</h3>
<select id="haha" size='7'>
<option>宽衣解带终不悔,为伊消得人憔悴</option>
<option>君子成人之美,小人夺人所爱</option>
<option>穷则独善其身,富则妻妾成群</option>
<option>后宫佳丽三千人,铁杵磨成绣花针</option>
<option>天若有情天亦老,人不风流枉少年</option>
</select>
<table>
<tr>
<td><button onclick="get('lbl1').innerText=get('haha').options[get('haha').selectedIndex].innerText">当前项</button></td>
<td id='lbl1'></td>
</tr>
<tr>
<td><button onclick="get('haha').multiple=true">设为多选</button></td>
<td><button onclick="get('haha').options.length=0">清空多选框</button></td>
</tr>
</table>
<script type="text/javascript">
function get(el)
{
return document.getElementById(el);
}
</script>
</body>
</html>


内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: