js select事件

<!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=utf-8" />
<script src="jquery/jquery.js"> </script>

<script type="text/javascript">
function eventHandler() {
var obj = document.getElementById('selectOption');
var index = obj.selectedIndex;

alert(obj.options[index].value);
$("#testDiv").append("Content:<br>");
$("#testDiv").removeAttr("style");

$("#testDiv").attr("style", "width: 1200px; height: 440px;border:1px solid blue; margin:auto;" );
}

</script>
</head>

<body>
<div id="testDiv"></div>
<select id='selectOption' onchange="eventHandler()">
<option value="ying" selected="selected">Ying</option>
<option value="saab">Saab</option>
<option value="opel">Opel</option>
<option value="audi">Audi</option>
</select>

<script type="text/javascript">

</script>
</body>
</html>

posted on 2012-12-05 15:25  evilying  阅读(3206)  评论(0编辑  收藏  举报

导航