现有一下拉列表内有两个option。我要用着两个option分别控制两个div的显示和隐藏。求大神,求代码。我现在的代码如下<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>select-option onclick </title>
<body>
<select >
<option onclick="red()" value="one">one</option>
<option onclick="blue()" value="two">two</option>
</select>
<div id="red" style="background:red;width:100px;height:60px;"></div>
<div id="blue" style="background:blue;width:60px;height:100px;"></div>
</body>
<script type="text/javascript">
function red() {
rr = document.getElementById("red");
rr.style.display = "block";
bb = document.getElementById("blue");
bb.style.display = "none"
}
function blue() {
rr = document.getElementById("red");
rr.style.display = "none";
bb = document.getElementById("blue");
bb.style.display = "blcok"
}
</script>
</html>
添加回答
举报
0/150
提交
取消