如何让JS,Script的ID延迟3秒后再执行相应动作?

怎么让下面的ID:capslide_img_ cont1,capslide_img_ cont2,延迟3秒后再执行?下面的JS代码,希望有热心网友回答。。。因为急用。。。 
 
 
这是一个鼠标放上去的效果,因为鼠标一路过,就会有闪动,所以想让它延迟,这样就不会太花哨了。。。
附上链接了: http://www.mpvvip.com/dins/le.html  
就是像让鼠标路过时,不要谎动,放鼠标放上3秒后,才往上滑。。。

前提是保持好原有的效果,能实现吗?

 

javascript模拟sleep
使用方法比较简单。

JS注释部份是修改后的新加参数:

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Home</title>
<link href="le_files/style.css" type="text/css" rel="stylesheet">
 </head>
<body>
<div class="demo">
    <div style="width: 210px; height: 170px; border: 0px none;" id="capslide_img_cont1" class="ic_container">
        <img src="le_files/baidu_sylogo1.gif" height="170" width="210" border="0">
        <div class="overlay" style="background-color: rgb(236, 236, 236); display: none;"></div>
        <div style="color: black; background-color: rgb(236, 236, 236); bottom: 0px; width: 210px;" class="ic_caption">
            <p class="ic_category">&nbsp;</p>
            <h3>服务员的快乐</h3>
            <p style="display: none;" class="ic_text">使用本系统服务员所得到的方便<br><img src="le_files/aan.gif" border="0">
            </p>
        </div>
    </div>
</div>

 

<div class="demo">
    <div style="width: 210px; height: 170px; border: 0px none;" id="capslide_img_cont2" class="ic_container">
        <img src="le_files/2_hksdn.gif" height="170" width="210" border="0">
        <div class="overlay" style="background-color: rgb(236, 236, 236); display: block; opacity: 0.969096;"></div>
        <div style="color: black; background-color: rgb(236, 236, 236); bottom: 0px; width: 210px;" class="ic_caption">
            <p class="ic_category">&nbsp;</p>
            <h3>服务员的快乐</h3>
            <p style="display: block; overflow: hidden; height: 34.525px; margin-top: 0px; margin-bottom: 0px; padding-top: 4.45108px; padding-bottom: 4.45108px;" class="ic_text">使用本系统服务员所得到的方便<br><img src="le_files/aan.gif" border="0">
            </p>
        </div>
    </div>
</div>
 


<script type="text/javascript" src="le_files/jquery-1.js"></script>
<script type="text/javascript">
function Pause(obj,iMinSecond){    
   if (window.eventList==null) window.eventList=new Array();    
   var ind=-1;    
   for (var i=0;i<window.eventList.length;i++){    
       if (window.eventList[i]==null) {    
         window.eventList[i]=obj;    
         iind=i;    
         break;    
        }    
    }    
   if (ind==-1){    
   ind=window.eventList.length;    
   window.eventList[ind]=obj;    
   }    
  setTimeout("GoOn(" + ind + ")",iMinSecond);    
}    
   
//js继续函数   
function GoOn(ind){    
  var obj=window.eventList[ind];    
  window.eventList[ind]=null;    
  if (obj.NextStep) obj.NextStep();    
  else obj();    
}

(function($) {
    $.fn.capslide = function(options) {
        var opts = $.extend({}, $.fn.capslide.defaults, options);
        return this.each(function() {
            $this = $(this);
            var o = $.meta ? $.extend({}, opts, $this.data()) : opts;
           
            if(!o.showcaption)    $this.find('.ic_caption').css('display','none');
            else $this.find('.ic_text').css('display','none');
               
            var _img = $this.find('img:first');
            var w = _img.css('width');
            var h = _img.css('height');
            $('.ic_caption',$this).css({'color':o.caption_color,'background-color':o.caption_bgcolor,'bottom':'0px','width':w});
            $('.overlay',$this).css('background-color',o.overlay_bgcolor);
            $this.css({'width':w , 'height':h, 'border':o.border});
            $this.hover(
                function () {
                    Pause(this,3000);//停留3秒后执行NextStep的function
                    this.NextStep=function(){
                        if((navigator.appVersion).indexOf('MSIE 7.0') > 0)
                        $('.overlay',$(this)).show();
                        else
                        $('.overlay',$(this)).fadeIn();
                        if(!o.showcaption)
                            $(this).find('.ic_caption').slideDown(500);
                        else
                            $('.ic_text',$(this)).slideDown(500);
                    }
                },
                function () {
                    Pause(this,1000);//停留3秒后执行NextStep的function
                    this.NextStep=function(){
                        if((navigator.appVersion).indexOf('MSIE 7.0') > 0)
                        $('.overlay',$(this)).hide();
                        else
                        $('.overlay',$(this)).fadeOut();
                        if(!o.showcaption)
                            $(this).find('.ic_caption').slideUp(200);
                        else
                            $('.ic_text',$(this)).slideUp(200);
                    }                   
                }
            );
        });
    };
    $.fn.capslide.defaults = {
        caption_color    : 'black',
        caption_bgcolor    : '#ECECEC',
        overlay_bgcolor : '#ECECEC',
        border            : '0',
        showcaption        : true
    };
})(jQuery);

 

 

$(function () {
    $("#capslide_img_cont1").capslide({
        caption_color    : 'black',
        caption_bgcolor    : '#ECECEC',
        overlay_bgcolor : '#ECECEC',
        border            : '0',
        showcaption        : true
    });
    $("#capslide_img_cont2").capslide({
        caption_color    : 'black',
        caption_bgcolor    : '#ECECEC',
        overlay_bgcolor : '#ECECEC',
        border            : '0',
        showcaption        : true
    });
});
           
</script>
</body></html>

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值