<!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" />
<title>下拉菜单中控制div显示或隐藏</title>
<script type="text/javascript" src="jquery.js"></script>
</head>
<body>
<div>
<div id="d1" style="">1111111111111</div>
<div id="d2" style="display:none;">2222222222222</div>
<div id="d3" style="display:none;">33333333333</div>
</div>
<select id="s">
<option value="1">java</option>
<option value="2">c</option>
<option value="3">net</option>
</select>
<script type="text/javascript">
var map = {"1":"d1", "2":"d2", "3":"d3"};
$("#s").bind("change", function(){
var divId = map[this.value];
$("#"+divId).show().siblings().hide();
}
);
</script>
</body>
</html>
来源:oschina
链接:https://my.oschina.net/u/1471509/blog/213653