I have the most basic jquery function of them all, but I couldn't find a way in the documentation to trigger the contents of this click function after say 1500 milliseconds:
我有他们最基本的jquery函数,但我在文档中找不到一种方法来触发这个点击函数的内容后说1500毫秒:
$('.masonryRecall').click(function(){
$('#mainContent').masonry();
});
P.S. just noticed the .delay function jquery 1.4, although, I am using version 1.3. I don't know whether updating this would interfere with any of the other javascript I currently have.
附:刚注意到.delay函数jquery 1.4,虽然我使用的是1.3版本。我不知道更新这个是否会干扰我目前拥有的任何其他JavaScript。
2 个解决方案
#1
17
You can do it with regular javascript using setTimeout()
.
你可以使用setTimeout()使用常规javascript来完成它。
$('.masonryRecall').click(function(){
setTimeout("$('#mainContent').masonry()", 1500);
});
#2
16
You should generally stay away from string literals in setTimeout/setInterval. Instead use a closure:
您通常应该远离setTimeout / setInterval中的字符串文字。而是使用一个闭包:
setTimeout(function(){ $('#mainContent').masonry(); }, 1500);`
and even better use it like this (note: the outer closure isn't really necessary):
甚至更好地使用它(注意:外部封闭不是真的必要):
(function($){
var timeout=null;
$('.masonryRecall').click(function(){
clearTimeout(timeout);
timeout=setTimeout(function(){$('#mainContent').masonry();}, 1500);
});
}(jQuery));
#1
17
You can do it with regular javascript using setTimeout()
.
你可以使用setTimeout()使用常规javascript来完成它。
$('.masonryRecall').click(function(){
setTimeout("$('#mainContent').masonry()", 1500);
});
#2
16
You should generally stay away from string literals in setTimeout/setInterval. Instead use a closure:
您通常应该远离setTimeout / setInterval中的字符串文字。而是使用一个闭包:
setTimeout(function(){ $('#mainContent').masonry(); }, 1500);`
and even better use it like this (note: the outer closure isn't really necessary):
甚至更好地使用它(注意:外部封闭不是真的必要):
(function($){
var timeout=null;
$('.masonryRecall').click(function(){
clearTimeout(timeout);
timeout=setTimeout(function(){$('#mainContent').masonry();}, 1500);
});
}(jQuery));