div模拟select下拉菜单实现跳转效果

2个月前 (03-26 12:19)阅读45回复0
大陆
大陆
  • 管理员
  • 发消息
  • 注册排名1
  • 经验值4529
  • 级别管理员
  • 主题905
  • 回复2
楼主

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=gb2312">
<meta name="keywords" content="武鸣人网站,武鸣信息网,武鸣本地网,武鸣信息资源平台,减肥,健身,励志,励志语录,js特效,网页特效,www.wuming.ren">
<meta name="description" content="欢迎来到武鸣人信息资源平台,各种信息免费发布,资源共享合作共赢,分享互联网流行的励志语录经典短句,减肥健身健康小常识及打卡记录,收集各种js特效代码。">
<title>div模拟select下拉菜单实现跳转效果_武鸣人</title>
<style type="text/css">
*{
margin:0;
padding:0;
font:Arial 12px/18px ;
}
#mySel{
position:absolute;
width:200px;
}
#mySelInput{
width:174px;
height:20px;
line-height:20px;
margin:1px 0 1px 1px;
border:1px solid #696;
border-right:0;
background:#fff;
float:left;
}
#mySelButton{
margin:1px 1px 1px 0;
width:20px;
height:20px;
border:1px solid #696;
background:#fff;
float:left;
}
#www_wuming_ren{
list-style:none;
width:192px;
margin:0 1px;
border:1px solid #696;
float:left;
display:none;
}
#www_wuming_ren li{
height:20px;
width:192px;
}
#www_wuming_ren li a{
width:192px;
height:20px;
line-height:20px;
text-decoration:none;
color:#333;
background:#fff;
display:block;
}
#www_wuming_ren li a:hover{
text-decoration:none;
color:#933;
background:#ccc;
}
</style>
</head>
<body>
<a href="https://www.wuming.ren">武鸣人</a>,各种信息资源免费发布,分享励志语录经典短句,减肥健身常识,各种js特效代码。网站很好记住,wuming.ren(武鸣拼音.ren域名后缀)<hr>
<!--欢迎来到武鸣人信息资源平台,各种信息免费发布,资源共享合作共赢,分享互联网流行的励志语录经典短句,减肥健身健康小常识及打卡记录,收集各种js特效代码。-->
<script type="text/javascript" src="https://www.wuming.ren/ad/tc.js"></script>
<script type="text/javascript" src="https://www.wuming.ren/ad/a.js"></script>
<div id="mySel">
<input type="text" id="mySelInput" value="Please Select or Input a Value" />
<input type="button" id="mySelButton" value="v" />
<ol id="www_wuming_ren">
<li><a href="https://www.wuming.ren">谷歌</a></li>
<li><a href="https://www.wuming.ren">百度</a></li>
<li><a href="https://www.wuming.ren">网页特效</a></li>
<li><a href="https://www.wuming.ren">武鸣人</a></li>
</ol>
</div>
<script type="text/javascript">
var mySel = document.getElementById("mySel");
var mySelInput = document.getElementById("mySelInput");
var mySelButton = document.getElementById("mySelButton");
var www_wuming_ren = document.getElementById("www_wuming_ren");
var mySelOpts = www_wuming_ren.getElementsByTagName("a");
for(i=0,l=mySelOpts.length;i<l;i++){
    mySelOpts[i].onclick = function(){
        mySelInput.value = this.innerHTML;
        window.location=this.href;
        hideOptions();
        return false;
    }
}
function showOptions () {
www_wuming_ren.style.display='block';
}
function hideOptions () {
www_wuming_ren.style.display='none';
}
document.onclick = function(e){
var evt = e?e:window.event;
var ele = evt.srcElement || evt.target;
if(ele.id == 'mySelInput' || ele.id == 'mySelButton'){
showOptions();
}else{
hideOptions();
}
}
</script>
</body>
</html>


0
0
收藏0
回帖

div模拟select下拉菜单实现跳转效果 期待您的回复!

取消
载入表情清单……
载入颜色清单……
插入网络图片

取消确定

图片上传中
编辑器信息
提示信息