最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

jquery 插件之仿“卓越亞馬遜”首頁彈出菜單效果

 更新時間:2008年12月25日 14:46:26   作者:  
用jquery實現(xiàn)的彈出菜單插件

復(fù)制代碼 代碼如下:

/*彈出式菜單*/
//沒劍 2008-07-03
//http://regedit.cnblogs.com
/*參數(shù)說明*/
//showobj:要顯示的菜單ID
//timeout:延時時間,鼠標停留/離開后延時多久開始顯示/隱藏菜單
//speed:菜單顯示速度,數(shù)字越大,顯示越慢,默認為100
//調(diào)用示例:$("#button").DMenu("#content");
jQuery.fn.DMenu=function(showobj,timeout,speed){
timeout=timeout?timeout:300;
speed=speed?speed:100;
//按鈕對象
var button=$(this);
//延時計數(shù)器
var timer=null;
//隱藏的浮動層
var hideDiv=$("<div></div>");
//容器對象
var Container=$("<div id=\"Container\"></div>");
Container.hide();
hideDiv.append(Container);
//菜單對象
var jqShowObj=$(showobj);
//隱藏菜單
jqShowObj.hide();
//菜單顯示的狀態(tài)
var display=false;
//按鈕的offset
var offset=button.offset();
//菜單區(qū)高
var height=jqShowObj.height();
//菜單區(qū)寬
var width=jqShowObj.width();
//按鈕的高
var btnHeight=button.height();
//按鈕的寬
var btnWidth=button.width();
//定位層放到最前面
$(document.body).prepend(hideDiv);
//放到容器中
//Container.append(jqShowObj);

//****顯示菜單方法開始****//
var showMenu=function(){
//如果菜單為顯示則退出操作
if (display)
{
return false;
}
//設(shè)置容器屬性
Container.css({
margin:"0 auto",
width:btnWidth+"px",
height:btnHeight+"px"
});
//定位隱藏層
hideDiv.css({
position:"absolute",
top:offset.top+"px",
left:offset.left+(btnWidth/2)-(width/2)+"px",
height:height+"px",
width:width+"px"
}).show();
//給容器加個黑邊框
Container.css({
border:"1px solid #666666"
});
//顯示定位層
//高寬慢慢增大
Container.animate({
marginTop:btnHeight+4,
height:height+4,
width:width+4,
opacity:'100'},speed,function(){
//動畫結(jié)束時 start//
//顯示菜單
jqShowObj.show();
//添加菜單入容器
Container.append(jqShowObj);
//去除邊框
Container.css({
border:"0px"
});
//顯示狀態(tài)置為true
display=true;
//鼠標移入
jqShowObj.mouseover(function(){
clearTimeout(timer);
});
//鼠標移開
jqShowObj.mouseout(function(){
hideMenu();
});
//動畫結(jié)束時 end//
});
};
//****顯示菜單方法結(jié)束****//

//****隱藏菜單方法開始****//
var hideMenu=function(){
clearTimeout(timer);
//延時隱藏菜單
timer=setTimeout(function(){
//顯示邊框
Container.css({
border:"1px solid #666666"
});
//清空容器
Container.empty();
//收縮容器
Container.animate({
width:btnWidth,height:btnHeight,marginTop:'0', opacity: '0'
}, speed,function(){
//動畫結(jié)束時 start//
//隱藏容器
Container.hide();
//定位層隱藏
hideDiv.hide();
//顯示狀態(tài)置為false
display=false;
//動畫結(jié)束時 end//
});
}, timeout);
};
//****隱藏菜單方法結(jié)束****//

//綁定按鈕鼠標經(jīng)過事件
button.hover(function(e){
//延時顯示菜單
clearTimeout(timer);
timer=setTimeout(function(){
showMenu();
}, timeout);
},function(){
clearTimeout(timer);
//鼠標離開按鈕時,如果菜單還是顯示狀態(tài)則隱藏
if(display){
timer=setTimeout(function(){
hideMenu();
},timeout);
}
});
};

注:對于select擋住彈出菜單的問題,因為與插件沒有關(guān)系,所以在此,偶沒有解決,放哪個select在哪只是想提醒大家使用彈出菜單時要注意到這個問題,具體的解決方法可以自動搜索,或者在排版上作調(diào)整。
文件打包下載

相關(guān)文章

最新評論

柘城县| 理塘县| 宜春市| 石城县| 两当县| 宜黄县| 麻江县| 翁牛特旗| 嘉祥县| 宁蒗| 桐柏县| 桂东县| 马尔康县| 北辰区| 六安市| 始兴县| 彝良县| 永清县| 西乡县| 运城市| 景德镇市| 利川市| 湛江市| 凤庆县| 咸丰县| 炎陵县| 盱眙县| 绍兴市| 溧阳市| 新绛县| 柞水县| 德江县| 黄梅县| 虹口区| 东乡族自治县| 梅州市| 密山市| 玉门市| 稻城县| 顺平县| 饶平县|