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

jquery仿百度經(jīng)驗(yàn)滑動切換瀏覽效果

 更新時間:2015年04月14日 11:59:04   投稿:hebedich  
本文給大家分享的是使用jQuery實(shí)現(xiàn)仿百度經(jīng)驗(yàn)華東切換瀏覽效果,非常的炫酷,推薦給大家。有需要的小伙伴可以參考下

jquery仿百度經(jīng)驗(yàn)滑動切換瀏覽效果

$(function() {
  wordStrong();
  $("#content ul").width($("#content ul li:first").width()*$("#content ul li").length);
  $("#header .top_right .vote").hover(function() {
    $(this).children(".hover-tip").css("display", "block");
    $(this).children(".num").css("display", "none");  
  }, function() {
    $(this).children(".hover-tip").css("display", "none");
    $(this).children(".num").css("display", "block");  
  });
   
   
  $("#content .left, #content .right").width(($(document).width()-$("#content").width())/4);
  $("#content .left").css("left", -$("#content .left").width());
  $("#content .right").css("right", -$("#content .right").width());
   
  var showId = 0;
  $("#content span.left").hover(function() {
    if ( checkFirst() ) return ;
    $(this).css("cursor", "pointer");
    $(this).siblings(".sl").stop().animate({
      opacity:0.5 
    }); 
  }, function() {
    $(this).siblings(".sl").stop().animate({
      opacity:0
    }); 
  }).click(function() {
    if ( checkFirst() ) return ;
    showId --;
    $("#content").attr("showId", showId);
    $("#footer li").children().removeClass("active").end().children().eq(showId).addClass("active");
    center(showId);
  });
   
  $("#content span.right").hover(function() {
    if ( checkLast() ) return ;
    $(this).css("cursor", "pointer");
    $(this).siblings(".sr").stop().animate({
      opacity:0.5
    }); 
  }, function() {
    $(this).siblings(".sr").stop().animate({
      opacity:0
    }); 
  }).click(function() {
    if ( checkLast() ) return ;  
    showId ++;   
    $("#content").attr("showId", showId);
    $("#footer li").children().removeClass("active").end().children().eq(showId).addClass("active");
    center(showId); 
  });
   
  function checkFirst() {
    if ( $("#content").attr("showId") == 0 ) {
      $("#content span.left").css("cursor", "default");
      return true;    
    }
    return false;
  }
   
  function checkLast() {
    if ( $("#content").attr("showId") == $("#content ul li").length-1 ) {
      $("#content span.right").css("cursor", "default");
      return true;    
    }
    return false;  
  }
     
  /* 首字母大寫 */
  function wordStrong() {
    var liList = $("#content ul li");
    for (var j = 0; j < liList.length; j ++) {
      var pList = $("#content .cont_"+(j+1)+" .cont_word p");
      for (var i = 0; i < pList.length; i ++) {
        var p = pList.get(i);
        var pCont = $(p).html();    
        var s = $("<b>"+(i+1)+"</b>");
        s.css("font-size", "24px");   
        $(p).html('');
        s.appendTo(p);
        $(p).append(pCont.substring(1));    
      }
    }
  }  
   
  center(0);
   
  //相對li居中
  function center(liIndex) {
    var li = $("#content ul li").css("opacity", 0.3).eq(liIndex).css("opacity", 1);
    $("#content ul").animate({
      left: (-li.width()*liIndex)
    });
  }
   
  var footLen = $("#content ul li").length;
  var foots = $("#footer ul");
  for (var i = 1; i < footLen-1; i ++) {
    var childA = $("<a>").html(i);
    childA.attr("href", "#");
    $("<li>").append(childA).insertBefore(foots.children("[step=last]")).attr("step", i);   
  }
  foots.children(":last").attr("step", footLen-1);
  foots.css("left", ($(window).width()-foots.width())/2); 
  $("#footer li").click(function() {
    $("#footer ul li").children().removeClass("active");
    $(this).children().addClass("active");
    center($(this).attr("step"));
  });
   
  function myAddEvent(obj, e, fn) {
    if ( obj.attachEvent ) {
      obj.attachEvent('on'+e, fn);
    }else obj.addEventListener(e, fn, false);
  }
   
  function onMouseWheel(ev) { 
    var ev = ev||event;   
    //IE
    //wheelDelta  下滾:負(fù), 上滾:下
    //alert(oEvent.wheelDelta);
    //FF
    //detail:  下滾:正, 上滾: 負(fù)
    //alert(oEvent.detail)   
    var bDown = true;
    if ( ev.wheelDelta ) {
      bDown = ev.wheelDelta<0;
    }else {
      bDown = ev.detail>0;
    }    
    if ( !bDown ) {
      if ( checkFirst() ) return ;
      showId --;     
    }
    else {
      if ( checkLast() ) return ;
      showId ++;     
    }
    $("#content").attr("showId", showId);
    $("#footer ul li").children().removeClass("active").end().eq(showId).children().addClass("active");
    center(showId);
    if ( oEvent.preventDefault ) {
      oEvent.preventDefault();
    }
    return false;
  }
   
  myAddEvent(window, 'mousewheel', onMouseWheel);
  myAddEvent(window, 'DOMMouseScroll', onMouseWheel);
});

以上所述就是本文給大家介紹的全部內(nèi)容了,希望大家能夠喜歡。

相關(guān)文章

  • jQuery+ajax讀取并解析XML文件的方法

    jQuery+ajax讀取并解析XML文件的方法

    這篇文章主要介紹了jQuery+ajax讀取并解析XML文件的方法,涉及jQuery的ajax方法調(diào)用xml文件及針對xml數(shù)據(jù)的遍歷與節(jié)點(diǎn)操作相關(guān)技巧,需要的朋友可以參考下
    2016-09-09
  • jQuery選擇器之屬性過濾選擇器詳解

    jQuery選擇器之屬性過濾選擇器詳解

    這篇文章主要為大家詳細(xì)介紹了jQuery選擇器之屬性過濾選擇器,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2017-09-09
  • jquery滾動加載數(shù)據(jù)的方法

    jquery滾動加載數(shù)據(jù)的方法

    這篇文章主要介紹了jquery滾動加載數(shù)據(jù)的方法,實(shí)例分析了jQuery動態(tài)加載數(shù)據(jù)的技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下
    2015-03-03
  • JQuery樣式與屬性設(shè)置方法分析

    JQuery樣式與屬性設(shè)置方法分析

    這篇文章主要介紹了JQuery樣式與屬性設(shè)置方法,結(jié)合實(shí)例形式分析了jQuery屬性的獲取與設(shè)置、以及樣式的添加與刪除相關(guān)操作技巧,需要的朋友可以參考下
    2019-12-12
  • 分享20款好玩的jQuery游戲

    分享20款好玩的jQuery游戲

    jQuery是時下最流行的 JavaScript 庫?,F(xiàn)在,除了HTML5以外,也有很多jQuery愛好者使用jQuery來開發(fā)游戲,雖然效果沒有Flash那么好,但是這些游戲也看起來很酷。
    2011-04-04
  • jQuery ajax應(yīng)用總結(jié)

    jQuery ajax應(yīng)用總結(jié)

    Ajax在Web應(yīng)用中的作用越來越大,許多工具都包含了對這一功能的使用,以下是對這些常用工具中Ajax的典型實(shí)例.
    2016-06-06
  • 輕松學(xué)習(xí)jQuery插件EasyUI EasyUI創(chuàng)建CRUD應(yīng)用

    輕松學(xué)習(xí)jQuery插件EasyUI EasyUI創(chuàng)建CRUD應(yīng)用

    這篇文章主要幫大家輕松學(xué)習(xí)jQuery插件EasyUI,并利用EasyUI創(chuàng)建CRUD應(yīng)用,感興趣的小伙伴們可以參考一下
    2015-11-11
  • JQuery選擇器用法詳解

    JQuery選擇器用法詳解

    本文詳細(xì)講解了JQuery選擇器的用法,文中通過示例代碼介紹的非常詳細(xì)。對大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2022-04-04
  • jQuery對象數(shù)據(jù)緩存Cache原理及jQuery.data方法區(qū)別介紹

    jQuery對象數(shù)據(jù)緩存Cache原理及jQuery.data方法區(qū)別介紹

    jQuery.data(..)來實(shí)現(xiàn)數(shù)據(jù)緩存,但有兩個用戶經(jīng)常使用的data([key],[value])和jQuery.data(element,[key],[value]),接下來為大家介紹下他們的區(qū)別,感興趣的朋友可以參考下哈
    2013-04-04
  • Eclipse下jQuery文件報(bào)錯出現(xiàn)錯誤提示紅叉

    Eclipse下jQuery文件報(bào)錯出現(xiàn)錯誤提示紅叉

    工程中加入jquery.xx.js文件,發(fā)現(xiàn)該文件出現(xiàn)錯誤提示(紅×),但使用Eclipse 3.7以前的版本就不會出現(xiàn)這種提示,下面有個不錯的解決方法,大家可以參考下
    2014-01-01

最新評論

赣榆县| 建阳市| 达州市| 凤翔县| 延边| 桦南县| 卢湾区| 永修县| 通许县| 孙吴县| 盘山县| 邛崃市| 牡丹江市| 德州市| 德钦县| 临海市| 车致| 南昌县| 广灵县| 浪卡子县| 徐水县| 汤阴县| 田东县| 林口县| 化州市| 霍邱县| 上犹县| 汕尾市| 凤庆县| 中阳县| 休宁县| 吉林省| 阿拉善左旗| 沾化县| 潮安县| 东源县| 临清市| 华安县| 汉沽区| 白银市| 台中市|