timeout - Auto hide and show div after 2 seconds -


I am very new to these types of scripts and would be very grateful for any help.

I have 3 rotating divs and want div1 to show for 2 seconds, then div2 to show for 2 seconds, then show div3 to 2 seconds and then the whole cycle I have to start from the beginning, there is a divis at one time while the other two is hidden. I would like to get rid of the click to start the function, but as soon as I go to the page to start the cycle.

I basically got the code from the following posts I got to work

jquery .fadein () and .fadeout () or .css ('display', 'none') and Use window.setInterval (FunctionName, 2000);

The function you enter in the first parameter every two seconds will run. Create a variable that you want to show about which Divis When Variable 3 goes, then you reset it to 1, so the process continues infinitely.

Edit:

Style:

  div {width: 500px; Height: 500px; Margin-left: 50px; Border: 1 px solid black; Swim left; Opacity: 0; } # Div3 {Opacity: 1; } Div: nth-child (Strange) {background: #dad; } Div: nth-child (even) {background: # a55; }   

jquery / js:

  var index = 1; Window.setInterval (ChangeWizibleDive, 2000); Change functionWidth () {var nextIndex = Index + 1; Var prevIndex = index - 1; // reset to 4, not 3, because then 3 DV will never be faded if (index == 4) next index = 1; // Unlike the story here as above (index == 1) prevIndex = 3; $ (("# Div" + prevIndex)). CSS ('Opacity', 0); $ (("# Div" + Next Index)). CSS ('Opacity', 0); $ (("# Div" + index)). CSS ('Opacity', 1); Index ++; // reset to 4, not 3, because then 3 DV will never fade if (index == 4) index = 1; }   

html

  & lt; Div id = "div1" & gt; & Lt; / Div & gt; & Lt; Div id = "div2" & gt; & Lt; / Div & gt; & Lt; Div id = "div3" & gt; & Lt; / Div & gt;   

It starts on the third div, I hope you do not have any brain because I'm lazy to fix =)

I really like you Jquery learning javascript, though If you do not know how it works, then it is not smart to use it. To learn at least fundamentals.

Besides, people want to have fun and challenging questions on this forum, not assignment from school =)

Comments

Popular posts from this blog

Python SQLAlchemy:AttributeError: Neither 'Column' object nor 'Comparator' object has an attribute 'schema' -

java - How not to audit a join table and related entities using Hibernate Envers? -

mongodb - CakePHP paginator ignoring order, but only for certain values -