js+div模拟下拉列表框

<html>
<head>
<title>模拟下拉列表框</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style>
body,td,div  {font:12px 宋体}
label        {height:19px;padding:3px 0px 0px 4px}
.link_box    {text-align:left;cursor:default}
.link_head   {width:100%;height:23;border:2px inset}
.link_text   {background:#fff;padding-left:2px}
.link_arrow0 {font:14px marlett;text-align:center;width:22;height:100%;border:2px outset;background:buttonface}
.link_arrow1 {font:14px marlett;text-align:center;width:22;height:100%;border:1px solid buttonshadow;padding:2px 0px 0px 2px;background:buttonface}
.link_value  {position:absolute;visibility:hidden;border:1px solid;overflow:auto;overflow-x:hidden;filter:alpha(opacity:0)}
.link_record0{width:100%;height:20;border-top:1px solid #eee;background:#fff;color:#000;padding-left:2px}
.link_record1{width:100%;height:20;border-top:1px solid #047;background:#058;color:#fe0;padding-left:2px}
</style>
<script>
var dropShow=false
var currentID
function dropdown(el){
if(dropShow){
dropFadeOut()
}else{
currentID=el
el.style.visibility="visible"
dropFadeIn()
}
}
function dropFadeIn(){//选单淡入的效果
if(currentID.filters.alpha.opacity<100){
currentID.filters.alpha.opacity+=20
fadeTimer=setTimeout("dropFadeIn()",50)
}else{
dropShow=true
clearTimeout(fadeTimer)
}
}
function dropFadeOut(){//选单淡出的效果
if(currentID.filters.alpha.opacity>0){
clearTimeout(fadeTimer)
currentID.filters.alpha.opacity-=20
fadeTimer=setTimeout("dropFadeOut()",50)
}else{
dropShow=false
currentID.style.visibility="hidden"
}
}
function dropdownHide(){
if(dropShow){
dropFadeOut()
dropShow=false
}
}
function hiLight(el){//高亮度显示指标位置
if(dropShow){
for(i=0;i<el.parentElement.childNodes.length;i++){
el.parentElement.childNodes(i).className="link_record0"
}
el.className="link_record1"
}
}
function CheckMe(el){//替换显示内容
el.parentElement.parentElement.childNodes(0).childNodes(0).childNodes(0).childNodes(0).childNodes(0).childNodes(0).innerHTML=el.innerHTML
}
document.οnclick=dropdownHide
</script>
</head>

<body bgcolor="#0099FF" text="#000000" onLoad="document.form1.reset()">
<table align="center" width="100%" height="100%">
<tr><td align="center">
<table width="380" align="center" cellpadding=4 cellspacing=2 bgcolor=#a0a0a0>
  <tr>
<td bgcolor=#ddeeff>范例1 (使用于表单)</td>
<td bgcolor=#ddeeff>范例2 (使用于超连结)</td>
</tr>
<tr><td bgcolor=#e0e0e0 align=center>
<!--// 范例 1 开始 //-->
<table><tr><form name=form1 onSubmit="alert(city.value);return false"><td>
<div class=link_box style="width:100px" onselectStart="return false">
<div class=link_head onClick="dropdown(value1)">
<table width=100% height=100% border=0 cellpadding=0 cellspacing=0><tr>
<td><div id=text1 class=link_text><label>请选择?</label></div></td>
<td width=22 align=right><div class=link_arrow0 onMouseDown="this.className='link_arrow1'" onMouseUp="this.className='link_arrow0'" onMouseOut="this.className='link_arrow0'">6</div></td>
</tr></table>
</div>
<div id=value1 class=link_value style="width:100%;height:100px">
<div class=link_record0 onMouseOver="hiLight(this)" onClick="CheckMe(this);document.form1.city.value=this.innerText"><label>北京市</label></div>
<div class=link_record0 onMouseOver="hiLight(this)" onClick="CheckMe(this);document.form1.city.value=this.innerText"><label>上海市</label></div>
<div class=link_record0 onMouseOver="hiLight(this)" onClick="CheckMe(this);document.form1.city.value=this.innerText"><label>河南省</label></div>
<div class=link_record0 onMouseOver="hiLight(this)" onClick="CheckMe(this);document.form1.city.value=this.innerText"><label>深圳市</label></div>
<div class=link_record0 onMouseOver="hiLight(this)" onClick="CheckMe(this);document.form1.city.value=this.innerText"><label>大连市</label></div>
<div class=link_record0 onMouseOver="hiLight(this)" onClick="CheckMe(this);document.form1.city.value=this.innerText"><label>云南省</label></div>
</div>
</div>
</td><td>
<input type="hidden" name="city" value="您尚未选择">
<input type="submit" value="确定">
</td></form></tr></table>
<!--// 范例 1 结束 //-->
</td>
<td bgcolor=#e0e0e0 align=center>
<!--// 范例 2 开始 //-->
<div class=link_box style="width:125px" onselectStart="return false">
<div class=link_head onClick="dropdown(value2)">
<table width=100% height=100% border=0 cellpadding=0 cellspacing=0>
  <tr>
<td><div class=link_text><label> 去哪个网站?</label></div></td>
<td align=right><div class=link_arrow0 onMouseDown="this.className='link_arrow1'" onMouseUp="this.className='link_arrow0'" onMouseOut="this.className='link_arrow0'">6</div></td>
</tr></table>
</div>
<div id=value2 class=link_value style="width:125px;height:125px">
<div class=link_record0 onMouseOver="hiLight(this)" onClick="CheckMe(this);window.open('http://lucky.myrice.com')"><label>【精彩世界】一</label></div>
<div class=link_record0 onMouseOver="hiLight(this)" onClick="CheckMe(this);window.open('http://lucky.myrice.com/')"><label>【精彩世界】二</label></div>
<div class=link_record0 onMouseOver="hiLight(this)" onClick="CheckMe(this);window.open('http://lucky.myrice.com')"><label>【精彩世界】三</label></div>
<div class=link_record0 onMouseOver="hiLight(this)" onClick="CheckMe(this);window.open('http://lucky.myrice.com/')"><label>【精彩世界】四</label></div>
<div class=link_record0 onMouseOver="hiLight(this)" onClick="CheckMe(this);window.open('http://lucky.myrice.com')"><label>【精彩世界】五</label></div>
<div class=link_record0 onMouseOver="hiLight(this)" onClick="CheckMe(this);window.open('http://lucky.myrice.com/')"><label>【精彩世界】六</label></div>
<div class=link_record0 onMouseOver="hiLight(this)" onClick="CheckMe(this);window.open('http://lucky.myrice.com')"><label>【精彩世界】七</label></div>
<div class=link_record0 onMouseOver="hiLight(this)" onClick="CheckMe(this);window.open('http://lucky.myrice.com/')"><label>【精彩世界】八</label></div>
</div>
</div>
<!--// 范例 2 结束 //-->
</td></tr>
</table>
</td></tr>
</table>
</body>
</html>
---------------------------------------------------------------------
引自: http://lucky.myrice.com
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值