Question

So I have this function that is supposed make some changes to an image (for a portfolio I'm making) and there is a button to change the image and there is also a timer that runs that changes the image every six seconds, however, as much as the button works 100% the timer does not, my firefox console tells me this: ReferenceError: nextone is not defined yet it is... What might be causing this?

My Script:

 function nextone() {
$("#portfolio1").fadeOut(500, function() {
    nextinline += 1;
    if(nextinline > jpgss) { nextinline = 1; }      
    $("#portfolio1").attr("src","images/portfolio/" + nextinline + ".jpg")
    $("#hyperlink").attr("href","portfolio.php?e=" + nextinline + "")
    $("#portfolio1").fadeIn(500);
    });
}
var timerr = setInterval("nextone()",6000); // Error Given on this line
Was it helpful?

Solution

try doing:

var timerr = setInterval(nextone,6000);

or

setInterval(function (){ 
  nextone() }, 6000);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top