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

首頁 > 編程 > JavaScript > 正文

jQuery實現鼠標經過像翻頁和描點鏈接效果

2019-11-20 09:16:56
字體:
來源:轉載
供稿:網友

在百度地圖api首頁經常見到當鼠標經過像翻頁和描點鏈接效果,基于jquery和js代碼是如何實現的呢?下面小編給大家分享關鍵代碼,一起看下吧!

var timer;$("li").on("mouseover",function(){clearTimeout(timer);timer=null;$(this).addClass("active");$(this).siblings().removeClass("active");var $index=$(this).index();/*$(".wrapper").animate({top:-$index*300});*/timer=setTimeout(function(){$(".wrapper").animate({top:-$index*300});},300)});$('.dd').find($(".cc")).hover(function(){$(this).find(".c1").stop().animate({width:0},100,function(){$(this).hide().next().show().animate({width:300},100);})},function(){$(this).find(".c2").animate({width:0},100,function(){$(this).hide().prev().show().animate({width:300},100);})}); *{margin:0;padding:0;box-sizing:border-box}ul{list-style:none;border:1px solid #ccc;border-radius:5px;width:900px;margin:30px auto 10px;}.clearfix{zoom:1;}.clearfix:after{content:".";display:block;width:0;height:0;visibility:hidden;clear: both;}li{float:left;border-right:1px solid #ccc;width:20%;text-align:center;height:30px;line-height:30px;cursor:pointer;}li:last-child{border:none;}li.active{background-color:#0099cc;color:#fff;}.container,.wrapper,.con{height:300px;}.container{width:900px;margin:0 auto;position:relative;overflow:hidden;}.wrapper{position:relative;top:0;}.con{line-height:300px;text-align:center;border:1px solid #ccc;}.dd{margin: 30px auto;width:1200px;}.cc{float:left;width:300px;height:200px;overflow:hidden;margin:20px;}.c1,.c2{width:100%;height:100%;margin:0 auto;text-align:center;line-height:200px;cursor:pointer;overflow:hidden}.c1{background-color:#c01110;}.c2{background-color:#0099cc;} <!DOCTYPE html><html><head lang="en"><meta charset="UTF-8"><title></title></head><body><!--<form action="#"><select name="" id="sel1"><option value="1">1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option><option value="5">5</option><option value="6">6</option></select><input type="submit" id="sub" value="提交"/></form>--><ul class="clearfix"><li class="active">選項1</li><li>選項2</li><li>選項3</li><li>選項4</li><li>選項5</li></ul><div class="container"><div class="wrapper"><div class="con">111111</div><div class="con">222222</div><div class="con">33333</div><div class="con">44444</div><div class="con">55555</div></div></div><div class="dd clearfix"><div class="cc"><div class="c1">111</div><div class="c2">222</div></div><div class="cc"><div class="c1">111</div><div class="c2">222</div></div><div class="cc"><div class="c1">111</div><div class="c2">222</div></div><div class="cc"><div class="c1">111</div><div class="c2">222</div></div><div class="cc"><div class="c1">111</div><div class="c2">222</div></div><div class="cc"><div class="c1">111</div><div class="c2">222</div></div></div></body></html>

下面給大家介紹下錨點鏈接

1)引入jquery

2)給a標簽設置class  smooth

3)

$(".smooth").click(function(){         var href = $(this).attr("href");         var pos = $(href).offset().top;         $("html,body").animate({scrollTop:pos}, 1000);         return false;  });

以上所述是小編給大家介紹的jQuery實現鼠標經過像翻頁和描點鏈接效果,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復大家的。在此也非常感謝大家對武林網網站的支持!

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 菏泽市| 松阳县| 武鸣县| 丽水市| 叙永县| 班玛县| 高安市| 庐江县| 资源县| 海安县| 称多县| 弋阳县| 班玛县| 曲靖市| 大城县| 靖安县| 罗田县| 临邑县| 九龙县| 徐州市| 南阳市| 赤峰市| 镇安县| 龙海市| 黑山县| 武冈市| 防城港市| 深泽县| 银川市| 鸡西市| 新乡县| 杭锦后旗| 海丰县| 遂川县| 渝北区| 曲松县| 平武县| 阿克陶县| 南雄市| 广德县| 南江县|