文章详细
js获取select值(兼容火狐、IE浏览器)
 2014/1/4 16:14:05 评论:0人 阅读次数:7338

本文介绍下,用js获取select中值的方法,可以兼容火狐firefox与IE浏览器,代码如下:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>js获取select值(兼容火狐、IE浏览器)www.86y.org</title>
</head>

<body>
<SELECT name="games" id="games" style="width:143px" onchange="chooseGeme()">
   <option value="1">test1</option>  
   <option value="2">test2</option>
   <option value="3">test3</option>
   <option value="4">test4</option>
   <option value="5">test5 </option>
   <option value="6">test6</option>  
</SELECT>
<script>
/**
* 取得select中的值
* edit www.86y.org
*/
function chooseGeme(){
  var games =document.getElementById("games");
  var gameoid = games.options[games.selectedIndex].value;
  alert(gameoid)
 }
</script>
</body>
</html>

(完)

如需转载请注明出处:http://www.86y.org/art_detail.aspx?id=674【js获取select值(兼容火狐、IE浏览器)】幸凡学习网
0
 
相关文章
推荐文章
Created By Charry-May 3,2010
粤ICP备10093478号-1
顶部