js如何判断选中而显示出指定内容?

来源:百度知道 编辑:UC知道 时间:2024/09/25 15:27:13
例如我的html代码如下:
成功对话:<select size="1" name="succeedtype">
<option value=0>对话框</option>
<option value=1>网页</option>
</select>
<div class="top3" id="thewait">选中了“网页”</div>

提问:
如何使用打开页面时,并没有显示id为“thewait”的<div>,但当用户选择了“网页”选项之后,出现id为“thewait”的<div>,当用户又选择了“对话框”选项后,则再次隐藏该<div>?

<script>
function a(v){
if(v==1){
document.all.thewait.style.display='block';
}else{
document.all.thewait.style.display='none';
}
}
</script>
<html>
例如我的html代码如下:
成功对话:<select size="1" name="succeedtype" onchange="a(this.value)">
<option value=0>对话框</option>
<option value=1>网页</option>
</select>
<div class="top3" id="thewait" style='display:none'>选中了“网页”</div>
</html>