简体   繁体   English

ReferenceError:未定义

[英]ReferenceError: not defined

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? 所以我有这个功能,应该对图像进行一些更改(对于我正在制作的作品集),并且有一个按钮可以更改图像,还有一个计时器,它每六秒钟运行一次,以更改图像。只要该按钮可以100%地运行,但计时器不能运行,我的firefox控制台会告诉我:ReferenceError:还没有定义nextone,这可能是什么原因引起的?

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

try doing: 尝试做:

var timerr = setInterval(nextone,6000);

or 要么

setInterval(function (){ 
  nextone() }, 6000);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM