jquery - if else conditions problems -
Hi, I have some problems with this function.
I want to create a carousel / slider with five sliders, click on the left arrow - 336px to the left of the first diva, but do not click on the next div (box 2).
On the left side, I do not know why the conditions are not verified.
& lt; Div class = "test" & gt; & Lt; Div id = "box1" class = "box_img" style = "background: black" & gt; & Lt; Img src = "picture / 1.jpg" /> & Lt; / Div & gt; & Lt; Div id = "box2" class = "box_img" style = "background: black" & gt; & Lt; Img src = "picture / 2.jpg" /> & Lt; / Div & gt; & Lt; Div id = "box3" class = "box_img" style = "background: black" & gt; & Lt; Img src = "picture / 4.jpg" /> & Lt; / Div & gt; & Lt; Div id = "box4" class = "box_img" style = "background: black" & gt; & Lt; Img src = "picture / 4 c. Jpg" /> & Lt; / Div & gt; & Lt; Div id = "box5" class = "box_img" style = "background: black" & gt; & Lt; Img src = "picture / 5.png" /> & Lt; / Div & gt; & Lt; / Div & gt; & Lt; Div class = "arrow" id = "arrow_left" & gt; & Lt; Img src = "picture / arrow_right.png" / & gt; & Lt; / Div & gt; & Lt; Div square = "arrow" id = "arrow_right" & gt; & Lt; Img src = "picture / arrow_left.png" / & gt; & Lt; / Div & gt;
function slide () {$ (document) .ready (function () {$ ("div.box_img"). I) {var first box = $ ("# box 1") var second box = $ ("# box2") var third box = $ ("# box 3"); var fourth box = $ ("# Box 4 "); var fifth box = $ (" # box 5 "); $ (" # arrow_left "). ({Click: work () {if (i = 1) {firstBox.animate ({" margin-left "(" - margin-left ":" - 336 px "}, if the second box (" - 336px "}, 400); // return (i & lt; 2);} and if (i = 2) 400); // Return (i & lt; 3);} Otherwise if (i = 3) {Third Box.Ammett ({"Margin-B Y "": "- 336 px"}, 400); // return (i <4);} and if (i = 4) {fourth box. {"Margin-left": "-336 px"}, 400 ); // Return (I and LT; 5);} and if (i = 5) {fiftheBox.animate ({"margin-left": "- 336px"}, 400); // return (i < 6);} and {warnings ("second ending");}}} // end click fn}) // console.log at end (i);}) // every}}};
Use ==
or = ==
You can now assign the assignment operator =
to compare.
Comments
Post a Comment