jquery inside the attr and CSS to set the carousel map unexpectedly effect inconsistent

Source: Internet
Author: User

/* Package $*///window.$=htmlelement.prototype.$=function (selector) {//var elems= (this==window?document:this)//. Que Ryselectorall (selector);//return elems.length==0?null:elems.length==1?elems[0]:elems;//}/* ad image array */var imgs=[{"I" : 0, "img": "Images/index/banner_01.jpg"}, {"I": 1, "img": "Images/index/banner_02.jpg"}, {"I": 2, "img": "images/index/ Banner_03.jpg "}, {" I ": 3," img ":" Images/index/banner_04.jpg "}, {" I ": 4," img ":" Images/index/banner_05.jpg "},];var adv ={liwidth:0, $ulImages: null, interval:1000, wait:3000, Timer:null, Init:function () {this.        Liwidth=parsefloat ($ (' #slider '). CSS ("width"));        this. $ulImages =$ ("#imgs");        This.updateview ();            $ ("#indexs"). On ("MouseOver", "Li", (e) =>{var target=$ ("#indexs >li"). Index (E.target);            var old=imgs[0].i;        This.move (Target-old);        });    This.automove (); }, Automove:function () {this.timer=settimeout (() =>this.move (1), thIs.    WAIT);        }, Movepre:function (n) {n*=-1;        Imgs=imgs.splice (-n,n). Concat (IMGs);        This.updateview (); this. $ulImages. css (' left ', parsefloat (this. $ulImages. CSS ("left")-n*this.    Liwidth);       }, Move:function (n) {cleartimeout (This.timer);           if (n<0) {this.movepre (n);           this. $ulImages. Stop (true); this. $ulImages. Animate ({left:0},this.           INTERVAL, () =>this.automove ())}else {this. $ulImages. Stop (true); this. $ulImages. Animate ({left:-n*this. Liwidth},this.       INTERVAL, () =>this.movecallback (n));        }}, Movecallback:function (n) {imgs=imgs.concat (Imgs.splice (0,n));        This.updateview ();        this. $ulImages. CSS ("left", 0);    This.automove (); }, Updateview:function () {for (Var i=0, lis= ", idxs="; i</li> '; lis+= ' <li> &Lt;img src= "${imgs[i].img}" ></li> ";        idxs+= ' <li></li> '; } this. $ulImages. html (LIS). CSS ("width", imgs.length*this.        Liwidth);        $ ("#indexs"). HTML (IDXS);        $ ("#indexs"). Children (": Nth-child (" +imgs[1].i+ ")"). AddClass ("hover");    $ ("#indexs"). Children (' Li:eq (${imgs[0].i}) '). addclass ("hover"); }};adv.init ();

Today, when I was writing a carousel, I found a small problem with jquery, and I really wanted to talk to you about it.

Above is the JS code of the Carousel diagram, and the strange is:

this. $ulImgs. CSS ("left", 0);
This.automove ();//Start Automatic carousel

This type of Carousel chart will have a sliding effect.

this. $ulImgs. attr ("left", 0);
This.automove ();//Start Automatic carousel

This writing does not have the effect of sliding, but it is also carousel, not smooth.

Find some information as follows

<a href= "#" style= "xxx" title= "alt=" ">xxx</a>

Two different Ah, CSS is related to style, attr can be obtained, such as the above Href,title,alt.


Since attr can also get can't set it???????????????????

jquery inside the attr and CSS to set the carousel map unexpectedly effect inconsistent

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.