js 下拉框控制div的显示
js 下拉框控制div的显示
<!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>js 下拉框控制div的显示</title>
</head>
<body>
<s cript>
function showandhide(v){
//alert(v);
for(i=1;i<3;i++){
document.getElementById(i).style.display = 'none';
if(i==v){
document.getElementById(v).style.display = 'block';
}
}
}
</s cript>
<select name="select" onchange = "showandhide(this.value)">
<option value="1">xxxx</option>
<option value="2">yyyy</option>
</select>
<div id="1">xxxx</div>
<div id="2" style="display:none;">yyyy</div>
<br /><br />
<input type="text" onkeyup="showIt(this.value)" />
<div id="show"></div>
<s cript>
function showIt(val){
document.getElementById('show').innerHTML=val;
}
</s cript>
<br /><br />
<s cript type="text/javas cript">
function selectTag(vv){
document.getElementById("kw").value=vv;
}
</s cript>
<div>
<a href="javas cript:void(0)" onClick="selectTag('网页')">网页</a>
<a href="javas cript:void(0)" onClick="selectTag('新闻')">新闻</a>
<a href="javas cript:void(0)" onClick="selectTag('地图')">地图</a>
<a href="javas cript:void(0)" onClick="selectTag('音乐')">音乐</a>
<a href="javas cript:void(0)" onClick="selectTag('图片')">图片</a>
</div>
<span>
<input id="kw" type="text" value="" size="30"></input>
</span>
</body>
</html>























![BrawlStars荒野乱斗同人[02]. by 丁几](https://img.zcool.cn/community/6ab9edd86422d4gs1pg5zx8755.png?k=15be60d616c0608b871edaee366137e4&t=6aeb5680&x-oss-process=image/resize,m_fill,w_520,h_390,limit_1/auto-orient,1/sharpen,100/quality,q_80)










