您的位置:首页 > 运维架构

访问列表框select中option选项

2016-06-14 22:50 351 查看
<!DOCTYPE html>
<html>
<head>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=GBK"/>
<title>Select选项</title>
</head>
<body>
<select id="fruitSelect" name="fruitSelect">
<option value="banana">香蕉</option>
<option value="apple">苹果</option>
<option value="orange">橘子</option>
<option value="pear">梨</option>
</select>
<input type="button" value="第一个" onclick="change(current.options[0]);"/>
<input type="button"  value="上一个" onclick="change(current.options[current.selectedIndex-1]);"/>
<input type="button" value="下一个" onclick="change(current.options[current.selectedIndex+1]);"/>
<input type="button" value="最后一个" onclick="change(current.options[current.length-1]);"/>
<script type="text/javascript">
var current=document.getElementById("fruitSelect");
function change(target){
alert(target.text);
}
</script>
</body>
</head>
</html>


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