国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 語言 > JavaScript > 正文

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

2024-05-06 14:16:25
字體:
供稿:網(wǎng)友

代碼如下:
/*彈出式菜單*/
//沒劍 2008-07-03
//http://regedit.cnblogs.com
/*參數(shù)說明*/
//showobj:要顯示的菜單ID
//timeout:延時(shí)時(shí)間,鼠標(biāo)停留/離開后延時(shí)多久開始顯示/隱藏菜單
//speed:菜單顯示速度,數(shù)字越大,顯示越慢,默認(rèn)為100
//調(diào)用示例:$("#button").DMenu("#content");
jQuery.fn.DMenu=function(showobj,timeout,speed){
timeout=timeout?timeout:300;
speed=speed?speed:100;
//按鈕對(duì)象
var button=$(this);
//延時(shí)計(jì)數(shù)器
var timer=null;
//隱藏的浮動(dòng)層
var hideDiv=$("<div></div>");
//容器對(duì)象
var Container=$("<div id=/"Container/"></div>");
Container.hide();
hideDiv.append(Container);
//菜單對(duì)象
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();
//給容器加個(gè)黑邊框
Container.css({
border:"1px solid #666666"
});
//顯示定位層
//高寬慢慢增大
Container.animate({
marginTop:btnHeight+4,
height:height+4,
width:width+4,
opacity:'100'},speed,function(){
//動(dòng)畫結(jié)束時(shí) start//
//顯示菜單
jqShowObj.show();
//添加菜單入容器
Container.append(jqShowObj);
//去除邊框
Container.css({
border:"0px"
});
//顯示狀態(tài)置為true
display=true;
//鼠標(biāo)移入
jqShowObj.mouseover(function(){
clearTimeout(timer);
});
//鼠標(biāo)移開
jqShowObj.mouseout(function(){
hideMenu();
});
//動(dòng)畫結(jié)束時(shí) end//
});
};
//****顯示菜單方法結(jié)束****//

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

發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表

圖片精選

主站蜘蛛池模板: 萍乡市| 望城县| 望都县| 吉安市| 浦县| 灵宝市| 抚顺县| 赤水市| 沈阳市| 京山县| 名山县| 肇庆市| 广宁县| 齐齐哈尔市| 察雅县| 遂宁市| 宜春市| 娱乐| 额尔古纳市| 泰兴市| 洛川县| 鄄城县| 六枝特区| 湖州市| 驻马店市| 保定市| 樟树市| 宁陵县| 陆良县| 义马市| 集安市| 星子县| 弋阳县| 金川县| 漯河市| 黄平县| 航空| 和顺县| 蒙阴县| 开封县| 七台河市|