problem with setTimeout "function is not define" !
problem with setTimeout "function is not define" !
What is the problem in this code ?
$(document).ready(function(){
function ISS_NextImage() { //ImageSlideShow NextImage
$('.ImageSl开发者_如何学JAVAideShow').each(function() {
alert($(".correntImage", this).text());
});
}
var t=setTimeout("ISS_NextImage();",1000);
});
When you eval
code, it is done in the global scope. Since the function you are trying to call is locally scoped, this fails.
Pass the function to setTimeout
instead of passing a string to be eval
ed.
var t=setTimeout(ISS_NextImage,1000);
Try changing your set timeout call to this:
var t=setTimeout(function(){ISS_NextImage();},1000);
Avoid passing a string to setTimeout(). Just pass a reference to the function instead:
var t = setTimeout(IIS_NextImage, 1000);
you could also:
$(function() {
var t = setTimeout(new function() {
$('.ImageSlideShow').each(function() {
alert($(".correntImage", this).text());
});
}, 1000);
});
You could do something like this:
$(document).ready(function(){
setTimeout(ISS_NextImage,1000);
});
function ISS_NextImage() {
$('.ImageSlideShow').each(function() {
alert($(".correntImage", this).text());
});
}
精彩评论