I have some problems, I have to do a slide show where the user has 4 buttons, and when they Click on a div and the other disappears. Div is all in the same size with the same place. I also like to keep it self-centered
var idx = 1; Var Interval = Set Internal = (Auto, 5000); Var Auto = function () {$ ("# Main Image"). Eq (idx) FadeIn (1000); While (idx <3) {id x ++; . $ ("# MainImage") eq (IDX) .hide (); } IDX ++; If (idx & gt; 3) {IDx = 0; }}; $ (". Botao-imagem") (function () {id x = $ (".ototao-imagem"). Index (this); auto ();});
Your main issue ID has been duplicated, the ID must be unique, so $ ("# Id"). Eq ()
Its purpose is not really, because it should be 1 or 0 results. Give the first elements a class instead:
& lt; Div class = "mainimage" & gt; & Lt; P & gt; 111111 & lt; / P & gt; & Lt; / Div & gt; & Lt; Div class = "main image" & gt; & Lt; P & gt; 222222 & lt; / P & gt; & Lt; / Div & gt; & Lt; Div class = "main image" & gt; & Lt; P & gt; 333333 & lt; / P & gt; & Lt; / Div & gt; & Lt; Div class = "main image" & gt; & Lt; P & gt; 444444 & lt; / P & gt; & Lt; / Div & gt;
And use a class selector like this:
$ ("MainImage")
Apart from this, automatically
needs to define it before using it or as a function, so in a complete way:
var idx = 0; Var Interval = Set Interval (Auto, 5000); Function auto () {$ ("MainImage"). Hide (). Eq (idx) FadeIn (1000); IDX ++; If (idx & gt; 3) id x = 0; }; $ (". Botao-imagem") (function () {id x = $ (".ototao-imagem"). Index (this); auto ();});
.
Comments
Post a Comment