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>