好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

div+css+jQuery图片横向滚动代码(带左右点击按钮)_html/css_WEB-ITnos

首先感谢Blue老师的javascript教程,给了我很多的启发,这是我在看完10 - 定时器的使用 - 2这节视频后,自己试着用jQuery重新改写了一下代码,感觉至少比百度搜出来的那一坨靠谱多了,上代码:

                         $(document).ready(function (){/*=============Author:GinoBlog:http://HdhCmsTestcnblogs测试数据/ginowang42Thanks:@Blue--http://HdhCmsTestzhinengshe测试数据/video.html#1Name:jQuery插件图片左右无缝滚动Arguments:    @leftBtn:向左滚动按钮DOM引用    @rightBtn:向右滚动按钮DOM引用    @speed:滚动速度(每次滚动像素数)CSS keyed Attribute:    #noSeamScroll{position:relative;overflow:hidden;}    #noSeamScroll ul{position:absolute;}        #noSeamScroll ul li {float:left;}    ===============*/    $.fn.extend({noSeamScroll:function (leftBtn,rightBtn,speed){        var timeFlag = speed = speed || 4;;        var timer = null;        var _this = this;//把this重新保存在一个私有变量里面,以防止setInterval误把this指向了window        this.oUl = $("ul",this);        this.oUl.html(this.oUl.html() + this.oUl.html());//把li复制一份        this.oLis = $("ul li",this);//之后再变量保存li的全部节点        this.oUl.width(this.oLis.eq(0).outerWidth(true)*this.oLis.length + "px");        var fnMove = function (){            $("ul",_this).css("left",function (){                if ($(this).position().left > 0){//这里的this指的是$("ul",element)                    return -$(this).outerWidth(true)/2 + "px";                }                if ($(this).position().left           *{margin:0;padding:0;}    #noSeamScroll{width:752px;height:108px;margin:20px auto;position:relative;overflow:hidden;}    #noSeamScroll ul{position:absolute;list-style:none;}        #noSeamScroll ul li {float:left;width:178px;height:108px;margin-right:10px;}               向左移动向右移动    

查看更多关于div+css+jQuery图片横向滚动代码(带左右点击按钮)_html/css_WEB-ITnos的详细内容...

  阅读:40次