求解,怎么使用JS(javascript)控制select隐藏层,我想选择我要隐藏时,隐藏div id="one"这个层
<div><selectname="termType"size="1"id="termType"style="width:150px"onChange="doProces...
<div> <select name="termType" size="1" id="termType" style="width:150px" onChange="doProcess([this.options.selectedIndex].value)">
<option value="1">我要隐藏</option>
<option value="2">我要显示</option>
</select>
<div>
<div id="one">呵呵,嘿嘿,呜呜</div> 展开
<option value="1">我要隐藏</option>
<option value="2">我要显示</option>
</select>
<div>
<div id="one">呵呵,嘿嘿,呜呜</div> 展开
展开全部
<script type="text/javascript">
function displayResult()
{
document.getElementById("one").style.visibility="hidden";
}
</script>
</head>
<body>
<div> <select name="termType" size="1" id="termType" style="width:150px;" onchange="displayResult()">
<option value="1" >我要隐藏</option>
<option value="2" selected="selected">我要显示</option>
</select>
</div>
<div id="one">呵呵,嘿嘿,呜呜</div></body>
</html>
function displayResult()
{
document.getElementById("one").style.visibility="hidden";
}
</script>
</head>
<body>
<div> <select name="termType" size="1" id="termType" style="width:150px;" onchange="displayResult()">
<option value="1" >我要隐藏</option>
<option value="2" selected="selected">我要显示</option>
</select>
</div>
<div id="one">呵呵,嘿嘿,呜呜</div></body>
</html>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
略微改进
<script language="javascript">
function displayResult()
{
var objSelect=objSelectdocument.getElementById("one")
objSelect.style.visibility=objSelect.options.selected.value;
}
</script>
</head>
<body>
<div> <select name="termType" size="1" id="termType" style="width:150px;" onchange="displayResult()">
<option value="hidden" >我要隐藏</option>
<option value="visible" selected="selected">我要显示</option>
</select>
</div>
<div id="one">呵呵,嘿嘿,呜呜</div></body>
</html>
<script language="javascript">
function displayResult()
{
var objSelect=objSelectdocument.getElementById("one")
objSelect.style.visibility=objSelect.options.selected.value;
}
</script>
</head>
<body>
<div> <select name="termType" size="1" id="termType" style="width:150px;" onchange="displayResult()">
<option value="hidden" >我要隐藏</option>
<option value="visible" selected="selected">我要显示</option>
</select>
</div>
<div id="one">呵呵,嘿嘿,呜呜</div></body>
</html>
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
<div> <select name="termType" size="1" id="termType" style="width:150px" onChange="doProcess(this.options[this.selectedIndex].value);">
<option value="2">我要显示</option>
<option value="1">我要隐藏</option>
</select>
<div>
<div id="one">呵呵,嘿嘿,呜呜</div>
<script type="text/javascript">
<!--
function doProcess(value)
{
if ( "1" == value) {
$("one").style.display = "none";
} else if ( "2" == value) {
$("one").style.display = "block";
}
}
function $(id)
{
return document.getElementById(id);
}
//-->
</script>
<option value="2">我要显示</option>
<option value="1">我要隐藏</option>
</select>
<div>
<div id="one">呵呵,嘿嘿,呜呜</div>
<script type="text/javascript">
<!--
function doProcess(value)
{
if ( "1" == value) {
$("one").style.display = "none";
} else if ( "2" == value) {
$("one").style.display = "block";
}
}
function $(id)
{
return document.getElementById(id);
}
//-->
</script>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询