Javascript 微调器最小延时Jquery
以下java脚本工作正常(Jquery)Javascript 微调器最小延时Jquery,javascript,jquery,ajax,Javascript,Jquery,Ajax,以下java脚本工作正常(Jquery) $(document).ready(function(){ $('#c_area').load($('.m_top:first').attr('href')) }); $('.m_top').click( function(){ $("#myDiv").html('<img src="images/loading.gif" alt="Wait" />'); var name= $(this).attr('href'); $('#c_ar
$(document).ready(function(){
$('#c_area').load($('.m_top:first').attr('href'))
});
$('.m_top').click( function(){
$("#myDiv").html('<img src="images/loading.gif" alt="Wait" />');
var name= $(this).attr('href');
$('#c_area').hide().load(name).fadeIn('normal');
$("#myDiv").html('');
return false;
});
$(文档).ready(函数(){
$('c#u area').load($('m#u top:first').attr('href'))
});
$('.m_top')。单击(函数(){
$(“#myDiv”).html(“”);
var name=$(this.attr('href');
$('c#u area').hide().load(name).fadeIn('normal');
$(“#myDiv”).html(“”);
返回false;
});
我希望显示加载图像(微调器)至少2秒,因为当页面已加载时,再次单击链接时,加载图像(微调器)不会再次显示,因为页面已加载
最短时间=2秒
最长时间=直到加载的内容使用delay()为止。以毫秒为单位给出秒数,如
$('#c_area').delay(2000).hide().load(name).fadeIn('normal');
//^ delay for 2 sec then hide
这是你的解决方案。
我使用setTimeout()在2秒后触发该函数
$('.m_top').click( function(){
var name= $(this).attr('href');
$('#c_area').html('<img src="images/loading.gif" alt="Wait" />');
setTimeout( function() {
$("#c_area").hide().load(name).fadeIn("normal");
},2000);
$("#myDiv").html('');
return false;
});
$('.m_top')。单击(函数(){
var name=$(this.attr('href');
$('c#u area').html(“”);
setTimeout(函数(){
$(“#c#U区域”).hide().load(name).fadeIn(“正常”);
},2000);
$(“#myDiv”).html(“”);
返回false;
});
绑定您的单击DOM ready
上的事件处理程序
$(document).ready(function() {
$('#c_area').load($('.m_top:first').attr('href'))
$('.m_top').click(function(event) {
$("#myDiv").html('<img src="images/loading.gif" alt="Wait" />');
var name = $(this).attr('href');
$('#c_area').hide().load(name).fadeIn('normal');
$("#myDiv").html('');
//return false;
event.preventDefault();
});
});
$(文档).ready(函数(){
$('c#u area').load($('m#u top:first').attr('href'))
$('.m_top')。单击(函数(事件){
$(“#myDiv”).html(“”);
var name=$(this.attr('href');
$('c#u area').hide().load(name).fadeIn('normal');
$(“#myDiv”).html(“”);
//返回false;
event.preventDefault();
});
});
您的代码工作正常,它在2秒后显示div,但在该延迟内不显示微调器。我还想延迟展示spinner!(loading.gif)(在此链接中我粘贴了一个示例)请查看,并在更新后发送电子邮件(信息)。shahid@yahoo.com)因为我想要快速的解决方案experts@BothFM,检查我的更新,已解决。通过创建一个提琴,我们可以比从skydrive下载更快地查看和修复代码。不管怎样,你的问题现在应该解决了。祝你好运;)