导航:首页 > 编程语言 > js缓冲下拉菜单

js缓冲下拉菜单

发布时间:2023-05-01 17:29:35

1. 下拉菜单缓缓展开js如何实现

这里有一念让冲个js的多级联动下拉菜单
可以自定义位置和样滑拿式仔歼 比较实用
里面有教程和源码

2. js函数怎么写:下拉菜单下拉菜单0_0

下拉菜单关键在于HTML的布局和CSS的样式写法。这有这两个写好了后,js操作起来才非常的简单。下面是简单例子,仅供参考:
<htmlxmlns="http://www.w3.org/1999/xhtml"lang="zh-CN">
<head><metahttp-equiv="Content-Type"content="text/html;charset=gb2312"/>
<title>js菜单演示_怎么使用js_js下拉菜单_简单js下拉菜单_怎么做js下拉菜单</title>
<styletype="text/css">
*{margin:0;padding:0;border:0;}
body{font-family:arial,宋体,serif;font-size:12px;}
#nav{line-height:24px;list-style-type:none;background:#666;}
#nava{display:block;width:80px;text-align:center;}
#nava:link{color:#666;text-decoration:none;}
#nava:visited{color:#666;text-decoration:none;}
#nava:hover{color:#FFF;text-decoration:none;font-weight:bold;}
#navli{float:left;width:80px;background:#CCC;}
#navlia:hover{background:#999;}
#navliul{line-height:27px;list-style-type:none;text-align:left;left:-999em;width:180px;position:absolute;}
#navliulli{float:left;width:120px;background:#F6F6F6;}
#navliula{display:block;width:100px;text-align:left;padding-left:20px;}
#navliula:link{color:#666;text-decoration:none;}
#navliula:visited{color:#666;text-decoration:none;}
#navliula:hover{color:#F3F3F3;text-decoration:none;font-weight:normal;background:#C00;}
#navli:hoverul{left:auto;}
#navli.onhoverul{left:auto;}
#content{clear:left;}
</style>
<scripttype="text/javascript">
functionmenu(){
varoLi=document.getElementById("nav").getElementsByTagName("li");
for(vari=0;i<oLi.length;i++){
oLi[i].onmouseover=function(){
this.className+=(this.className.length>0?"":"")+"onhover";
};
oLi[i].onMouseDown=function(){
this.className+=(this.className.length>0?"":"")+"onhover";
}
oLi[i].onMouseUp=function(){
this.className+=(this.className.length>0?"":"")+"onhover";
};
oLi[i].onmouseout=function(){
this.className=this.className.replace(newRegExp("(?|^)onhover"),"");}}}
window.onload=menu;
</script></head>
<body>
<ulid="nav">
<li><ahref="http://jingyan..com/article/fc07f98917a56f12ffe5198a.html"target="_blank">动漫之家</a>
<ul>
<li>
<ahref="http://jingyan..com/article/363872ecedf4486e4ba16f92.html"target="_blank">下拉一</a></li>
<li><ahref="http://jingyan..com/article/363872ecedf4486e4ba16f92.html"target="_blank">下拉二</a></li>
<li><ahref="http://jingyan..com/article/363872ecedf4486e4ba16f92.html"target="_blank">下拉三</a></li>
<li><ahref="http://jingyan..com/article/363872ecedf4486e4ba16f92.html"target="_blank">下拉四</a></li>
</ul></li><li><ahref="http://jingyan..com/article/e73e26c0cfa01724adb6a795.html"target="_blank">js详解</a><ul>
<li><ahref="http://jingyan..com/article/e73e26c0cfa01724adb6a795.html"target="_blank">下拉一</a></li>
<li><ahref="http://jingyan..com/article/e73e26c0cfa01724adb6a795.html"target="_blank">下拉二</a></li>
<li><ahref="http://jingyan..com/article/e73e26c0cfa01724adb6a795.html"target="_blank">下拉三</a></li>
<li><ahref="http://jingyan..com/article/e73e26c0cfa01724adb6a795.html"target="_blank">下拉四</a></li></ul></li>
<li><ahref="http://jingyan..com/article/08b6a591f09cfc14a8092293.html"target="_blank">js运用</a>
<ul><li><ahref="http://jingyan..com/article/08b6a591f09cfc14a8092293.html"target="_blank">下拉一</a></li>
<li><ahref="http://jingyan..com/article/08b6a591f09cfc14a8092293.html"target="_blank">下拉二</a></li>
<li><ahref="http://jingyan..com/article/08b6a591f09cfc14a8092293.html"target="_blank">下拉三</a></li>
<li><ahref="http://jingyan..com/article/08b6a591f09cfc14a8092293.html"target="_blank">下拉四</a></li></ul></li>
<li><ahref="http://jingyan..com/article/363872ecedf4486e4ba16f92.html"target="_blank">关于我们</a>
<ul><li><ahref="http://jingyan..com/article/363872ecedf4486e4ba16f92.html"target="_blank">下拉一</a></li>
<li><ahref="http://jingyan..com/article/363872ecedf4486e4ba16f92.html"target="_blank">下拉二</a></li>
<li><ahref="http://jingyan..com/article/363872ecedf4486e4ba16f92.html"target="_blank">下拉三</a></li>
<li><ahref="http://jingyan..com/article/363872ecedf4486e4ba16f92.html"target="_blank">下拉四</a></li>
</ul></li><li><ahref="http://jingyan..com/article/cdddd41c5e873153cb00e193.html"target="_blank">js在线演示</a>
<ul><li><ahref="http://jingyan..com/article/cdddd41c5e873153cb00e193.html"target="_blank">下拉一</a></li>
<li><ahref="http://jingyan..com/article/cdddd41c5e873153cb00e193.html"target="_blank">下拉二</a></li>
<li><ahref="http://jingyan..com/article/cdddd41c5e873153cb00e193.html"target="_blank">下拉三</a></li>
<li><ahref="http://jingyan..com/article/cdddd41c5e873153cb00e193.html"target="_blank">下拉四</a></li></ul></li>
<li><ahref="http://jingyan..com/article/76a7e409bb3c33fc3b6e1593.html"target="_blank">联系我们</a>
<ul><li><ahref="http://jingyan..com/article/76a7e409bb3c33fc3b6e1593.html"target="_blank">下拉一</a></li>
<li><ahref="http://jingyan..com/article/76a7e409bb3c33fc3b6e1593.html"target="_blank">下拉二</a></li>
<li><ahref="http://jingyan..com/article/76a7e409bb3c33fc3b6e1593.html"target="_blank">下拉三</a></li>
<li><ahref="http://jingyan..com/article/76a7e409bb3c33fc3b6e1593.html"target="_blank">下拉四</a></li></li></ul>
</body>
</html>

3. 用js写一个延迟下拉的二级菜单

$(".nav .tit").bind("hover",function(){
var _this = this;
setTimeout(function(){
$(_this).find(".box").show();

},1000);

});
手敲,求采纳!

4. 关于下拉菜单的JS代码

<styletype="巧灶text/css">

mainMenu{

background-color:FFF;/*Backgroundcolorofmainmenu*/

font-family:TrebuchetMS,LucidaSansUnicode,Arial,sans-serif;/*Fontsofmainmenuitems*/

font-size:1.2em;/*Fontsizeofmainmenuitems*/

border-bottom:1pxsolid000000;/*Bottomborderofmainmenu*/

height:30px;/*Heightofmainmenu*/

position:relative;/*Don&#*/

visibility:hidden;

}

mainMenua{

padding-left:20px;/**/

padding-right:20px;/**/

font-weight:bold;

/*Don'tchangethesetwooptions*/

position:absolute;

bottom:-1px;

}

submenu{

font-family:TrebuchetMS,LucidaSansUnicode,Arial,sans-serif;/*Fontofsubmenuitems*/

background-color:E2EBED;/*Backgroundcolorofsubmenuitems*/

visibility:hidden;

width:778px;/*Don'tchangethisoption*/

}

html>bodyclearmenu{/**/

margin-bottom:2px;

}

submenudiv{

white-space:nowrap;/*Don'tchangethisoption*/

}

/*

*/

mainMenu.activeMenuItem{

/*Borderoptions*/

border-left:1pxsolid000000;

border-top:1pxsolid000000;

border-right:1pxsolid000000;

background-color:E2EBED;/*Backgroundcolor*/

cursor:pointer;/**/

}

/*

*/

mainMenu.inactiveMenuItem{

color:000;/*Textcolor*/

cursor:pointer;/**/

}

submenua{

text-decoration:none;/*Nounderlineonsubmenuitems-usetext-decoration:underline;*/

padding-left:5px;/**/

padding-right:5px;/**/

color:000;/*Textcolor*/

}

submenua:hover{

color:FF0000;/**/

}

</style>孝腊扮

<scripttype="text/javascript">局乎

//morejavascriptfrom/support/analyzer/manual/html/General/CookiesJavaScript.htm

*/

functionGet_Cookie(name){

varstart=document.cookie.indexOf(name+"=");

varlen=start+name.length+1;

if((!start)&&(name!=document.cookie.substring(0,name.length)))returnnull;

if(start==-1)returnnull;

varend=document.cookie.indexOf(";",len);

if(end==-1)end=document.cookie.length;

returnunescape(document.cookie.substring(len,end));

}

//

functionSet_Cookie(name,value,expires,path,domain,secure){

expires=expires*60*60*24*1000;

vartoday=newDate();

varexpires_date=newDate(today.getTime()+(expires));

varcookieString=name+"="+escape(value)+

((expires)?";expires="+expires_date.toGMTString():"")+

((path)?";path="+path:"")+

((domain)?";domain="+domain:"")+

((secure)?";secure":"");

document.cookie=cookieString;

}

functionshowHide()

{

if(activeMenuItem){

activeMenuItem.className='inactiveMenuItem'

vartheId=activeMenuItem.id.replace(/[^d]/g,'');

document.getElementById('submenu_'+theId).style.display='none'

}

activeMenuItem=this;

this.className='activeMenuItem'

vartheId=this.id.replace(/[^d]/g,'');

document.getElementById('submenu_'+theId).style.display='block'

if(rememberActiveTabByCookie){

Set_Cookie('dhtmlgoodies_tab_menu_tabIndex','index:'+(theId-1),100);

}

}

functioninitMenu()

{

varmainMenuObj=document.getElementById('mainMenu');

varsubMenuObj=document.getElementById('submenu');//DDaddedline

mainMenuObj.style.visibility=subMenuObj.style.visibility="visible"//DDaddedline

varmenuItems=mainMenuObj.getElementsByTagName('A');

if(document.all){

mainMenuObj.style.visibility='hidden'

document.getElementById('submenu').style.visibility='hidden'

}

if(rememberActiveTabByCookie){

varcookieValue=Get_Cookie('dhtmlgoodies_tab_menu_tabIndex')+''

cookieValue=cookieValue.replace(/[^d]/g,'');

if(cookieValue.length>0&&cookieValue<menuItems.length){

activeTabIndex=cookieValue/1;

}

}

varcurrentLeftPos=15;

for(varno=0;no<menuItems.length;no++){

if(activateSubOnClick)menuItems[no].onclick=showHide;elsemenuItems[no].onmouseover=showHide;

menuItems[no].id='mainMenuItem'+(no+1);

menuItems[no].style.left=currentLeftPos+'px'

currentLeftPos=currentLeftPos+menuItems[no].offsetWidth+topMenuSpacer;

if(no==activeTabIndex){

menuItems[no].className='activeMenuItem'

activeMenuItem=menuItems[no];

}elsemenuItems[no].className='inactiveMenuItem'

if(!document.all)menuItems[no].style.bottom='-1px'

}

varmainMenuLinks=mainMenuObj.getElementsByTagName('A');

varsubCounter=1;

varparentWidth=mainMenuObj.offsetWidth;

while(document.getElementById('submenu_'+subCounter)){

varsubItem=document.getElementById('submenu_'+subCounter);

if(leftAlignSubItems){

//Noaction

}else{

varleftPos=mainMenuLinks[subCounter-1].offsetLeft;

document.getElementById('submenu_'+subCounter).style.paddingLeft=leftPos+'px'

subItem.style.position='absolute'

if(subItem.offsetWidth>parentWidth){

leftPos=leftPos-Math.max(0,subItem.offsetWidth-parentWidth);

}

subItem.style.paddingLeft=leftPos+'px'

subItem.style.position='static'

}

if(subCounter==(activeTabIndex+1)){

subItem.style.display='block'

}else{

subItem.style.display='none'

}

subCounter++;

}

if(document.all){

mainMenuObj.style.visibility='visible'

document.getElementById('submenu').style.visibility='visible'

}

document.getElementById('submenu').style.display='block'

}

window.onload=initMenu;

</script>

<divid="mainMenu">

<a>网页特效</a>

<a>插件下载</a>

<a>网络学院</a>

<a>网站联盟</a>

</div>

<divid="submenu">

<!--Thefirstsubmenu-->

<divid="submenu_1">

<ahref="javascript.asp?type=图形图像">图形图像</a>

<ahref="javascript.asp?type=鼠标事件">鼠标事件</a>

<ahref="javascript.asp?type=时间日期">时间日期</a>

<ahref="javascript.asp?type=导航菜单">导航菜单</a>

<ahref="javascript.asp?type=文字效果">文字效果</a>

<ahref="javascript.asp?type=窗体变化">窗体变化</a>

</div>

<!--Secondsubmenu-->

<divid="submenu_2">

<ahref="plug.asp?type=DreamWeaver插件">DreamWeaver插件</a>

<ahref="plug.asp?type=FireWork插件"FireWork插件</a>

<ahref="plug.asp?type=PhotoShop插件">PhotoShop插件</a>

<ahref="plug.asp?type=FLASH组件">FLASH组件</a>

</div>

<!--Thirdsubmenu-->

<divid="submenu_3">

<ahref="study.asp?type=网页制作">网页制作</a>

<ahref="study.asp?type=网络编程">网络编程</a>

<ahref="study.asp?type=图形图像">图形图像</a>

<ahref="study.asp?type=多媒体制作">多媒体制作</a>

<ahref="study.asp?type=网站建设">网站建设</a>

<ahref="study.asp?type=操作系统">操作系统</a>

</div>

<!--Fourthsubmenu-->

<divid="submenu_4">

<ahref="webmeng_show.asp?type=1">网页设计</a>

<ahref="webmeng_show.asp?type=2">艺术创作</a>

<ahref="webmeng_show.asp?type=3">电脑网络</a>

<ahref="webmeng_show.asp?type=4">生活休闲</a>

<ahref="webmeng_show.asp?type=5">个性展示</a>

<ahref="webmeng_show.asp?type=6">其它类型</a>

</div>

</div>

<brid="clearmenu"/>

5. JS下拉菜单

直接写了一下,不知道是不是你想要的,
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script type="text/javascript">
function clickA(){
document.form1.textname.style.display="";
document.form1.selectname.style.display="none";
}
function clickB(){
document.form1.textname.style.display="none";
document.form1.selectname.style.display="";
}
</script>
</head>
<body>
<form name="form1" action="">
<select>
<option onclick="clickA()">A</option>
<option onclick="clickB()">B</option>
</select>
<input type="text" name="textname" style="display:none;" >
<select name="selectname" style="display:none;">
<option>A</option>
<option>B</option>
</select>
</form>
</body>
</html>

6. JS的下拉菜单,总是在页面都载入后鼠标放上才会出现下拉

window.onload=menuFix;

改成

setTimeout(menuFix,999);

7. JS菜单下拉框问题,熟悉js的帮我看看,鼠标移除下拉不会消失

既然你使用的是JQ,那就春正可以用另外一个方法

$(".fxnmenuulli,.fxnnav_invest").hover(function(){鼠标over的时激森雹候执行显示},function(){鼠标out的时候执明帆行隐藏});

8. 怎么用JS写个下拉菜单

其实思路很容易的,先做大导航。然后做下拉菜单,但是下拉菜单默认是display:专none;当鼠标指向上边属的大导航的项目的时候(mouseover),对应的下拉菜单的CSS样式中的display属性设置为block,mouseout的时候又置为none;

9. 利用JS实现新浪下拉菜单

<style>

        .clearfix::after {

            display: block;

            content: "";

            clear: both;

        }

        ul,

        li {

            list-style: none;

        }

        .nav>li {

            float: left;

            margin: 0 10px;

        }

        .nav>li ul {

            display: none;

        }

    </style>

</head>

<body>

    <ul class="nav clearfix">

        <li>

            <a href="">微博</a>

            <ul>

                <li>私信</li>

                <li>评论</li>

                <li>@我</li>

            </ul>

        </li>

        <li>

            <a href="">微博</a>

            <ul>

                <li>私信</li>

                <li>评论</li>

                <li>@我</li>

            </ul>

        </li>

        <li>

            <a href="">微博</a>

            <ul>

                <li>私信</li>

                <li>评论</li>

                <li>@我</li>

            </ul>

        </li>

        <li>

            <a href="">微博</a>

            <ul>

                <li>私信</li>

                <li>评论</li>

                <li>@我</li>

            </ul>

        </li>

    </ul>

    <script>

        //案例分析:导航栏里面的li都要有鼠标经过效果 所以需要循环注册鼠标事件

        //核心原理:当鼠标经过li里面的第二个孩子ul显示 当鼠标离开 ul隐藏

        var nav = document.querySelector('.nav');

        var lis = nav.children;

        for (var i = 0; i < lis.length; i++) {

            lis[i].onmouseover = function() {

                this.children[1].style.display = 'block';

            }

            lis[i].onmouseout = function() {

                this.children[1].style.display = 'none';

            }

        }

    </script>

10. 用js做网页下拉菜单缓慢向下的特效代码

<!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>下拉菜单</title>
<style type="text/css">
*{margin:0; padding:0}
#nav{width:200px; margin:50px}
#nav h3{ cursor:pointer; line-height:30px; height:30px; background-color:#000000; color:#fff}
#nav a{display:block; line-height:24px;color:#666666}
#nav a:hover{background-color:#eee; color:#000;}
#nav div{display:none; border:1px solid #000; border-top:none}
</style>
<script type="text/javascript">
function $(id){return document.getElementById(id)}
window.onload = function(){
$("nav").onclick = function(e){
var src = e?e.target:event.srcElement;
if(src.tagName == "H3"){
var next = src.nextElementSibling || src.nextSibling;
next.style.display = (next.style.display =="block")?"none":"block";
}
}
}
</script>
</head>
<body>
<div id="nav">
<h3>管理区</h3>
<div>
<a href="#">建议</a>
<a href="#">链接</a>
<a href="#">联系</a>
</div>
<h3>交流区</h3>
<div>
<a href="#">JavaScript</a>
<a href="#">Delphi</a>
<a href="#">VC++</a>
</div>
</div>
</body>
</html>

阅读全文

与js缓冲下拉菜单相关的资料

热点内容
ps前往文件夹 浏览:694
信捷plc编程用哪个软件 浏览:939
vba导入文件 浏览:690
更新后版本英文怎么说 浏览:267
桌面云配置文件分离 浏览:505
iphone5如何升级4g网络 浏览:5
团购是在哪个app 浏览:897
打开多个word文档图片就不能显示 浏览:855
腾讯新闻怎么切换版本 浏览:269
app安装失败用不了 浏览:326
桌面文件鼠标点开会变大变小 浏览:536
手机误删系统文件开不了机 浏览:883
微信兔子甩耳朵 浏览:998
android蓝牙传文件在哪里 浏览:354
苹果6s软解是真的吗 浏览:310
c语言代码量大 浏览:874
最新网络卫星导航如何使用 浏览:425
以下哪些文件属于图像文件 浏览:774
zycommentjs 浏览:414
确认全血细胞减少看哪些数据 浏览:265

友情链接