因此,我有一个或两个函数,希望在页面加载10秒后运行。下面是现在的代码:
jQuery(document).ready(function() {
jQuery(".expand-cnt-link").click(function() {
jQuery(this).toggleClass("ecf_closed").parent(".exp-col-content-holder").find(".hidden-content").first().stop().slideToggle("slow").css("display","inline-block");
return false;
});
jQuery(".expand-cnt-link").toggleClass("ecf_closed").parent(".exp-col-content-holder").find(".hidden-content").css("display","none");具体来说,我正在寻找当前由单击元素".expand-cnt-link“触发的代码,而不是由加载了10秒的页面触发的代码。
我已经阅读了这篇文章:JQuery wait x seconds after document ready
这似乎表明正确的代码应该是:
jQuery(document).ready(function() {
setTimeout(function() {
jQuery(this).toggleClass("ecf_closed").parent(".exp-col-content-holder").find(".hidden-content").first().stop().slideToggle("slow").css("display","inline-block");
return false;
}, 2000);
jQuery(".expand-cnt-link").toggleClass("ecf_closed").parent(".exp-col-content-holder").find(".hidden-content").css("display","none");然而,这并没有给我任何luck...any建议?
发布于 2016-03-16 13:55:34
使用上面代码块中的代码,在页面加载10秒后调用单击函数,如下所示:
setTimeout(function() { jQuery(".expand-cnt-link").click() }, 10000);https://stackoverflow.com/questions/36025193
复制相似问题