javascript - Making a quote roller with buttons and timer -


We are trying to create a quote roller with buttons and a timer. We've got a lot, but at this point the button will not work correctly here is a jsfiddle:

and here the code

  on quote = ["Quote1 and are lt; br & gt; & lt; br & gt; - Repomeri "," Quote2 & lt; br & gt; & lt; br & gt; - Emmi "," Quote3 & lt; br & gt; & lt; br & gt; - Taateli "," Quote4 & lt; br & gt; & lt; br & gt; - Joonas "," coat 5 & lt; br & gt; & lt; br & gt; - Skelinn ",]; Var i = 0; Var timer = null; setInterval (function () {$ ( "# slideContainer") HTML (quote [i]) ;. if (i == quotes.length) {i = 0;} else {i ++;}}, 4 * 1000) ; Var b 1 = document.getElementById ( 'B-1'), B 2 = document.getElementById ( 'B2'), B 3 = document.getElementById ( 'B3'), B 4 = document.getElementById ( 'B4 '), B5 = document.getElementById (' B5 '); B1.onclick = function () {$ ("# slideContainer"). Html (quote [i]); I = 0; }; B2.onclick = function () {$ ("# slideContainer") Html (quote [i]); I = 1; }; B3.onclick = function () {$ ("# slideContainer") Html (quote [i]); I = 2; }; B4.onclick = function () {$ ("# slideContainer"). Html (quote [i]); I = 3; }; B5.onclick = function () {$ ("# slideContainer") Html (quote [i]); I = 4; };  

I think that is to put work for you i before calling html (quote [i]). For example:

  b1.onclick = function () {i = 0; $ ("# SlideContainer") HTML (citation [i]). };  

Comments