Home  >  Article  >  Web Front-end  >  jQuery simulation explosion countdown function technology sharing

jQuery simulation explosion countdown function technology sharing

小云云
小云云Original
2017-12-30 15:08:561635browse

This article mainly introduces you to the jQuery simulated explosion countdown function example code. It is very good. The code is simple and easy to understand. Friends who need it can refer to it. I hope it can help everyone better implement the jQuery simulated explosion countdown function.

HTML part

 
 
 
   
  *倒计时 
   
   
   

          

            

                            

   

js code snippet

$(function(){ 
  //让图片内容先隐藏 
  $(".content").hide(); 
  //添加input点击事件 
  $(".btn").click(function(){ 
    //设置一个值用来表示从多少秒开始倒计时 
    var time=3; 
    //setInterval(function(){},1000)方法可按照指定的周期(以毫秒计)来调用函数或计算表达式,也就是会根据你给的时间执行事件 1000是毫秒=1秒 
    var set=setInterval(function(){ 
      //判断上面的time倒计时时间是否为0 
      if(time>0){ 
        //不为0时每过一秒就减一秒 
        $(".min").text(time-- +"(s)"); 
        //同时当倒计时不为0时,让content显示出来但火花图片隐藏 
        $(".content").show(); 
        $(".content .img2").hide(); 
      }else{//否则当倒计时=0时,倒计时结束,将数字与*隐藏,显示火花图片 .img1,p中 “,”是选择两个同级标签元素 
        $(".content .img1,p").hide(); 
        $(".content .img2").show(); 
      } 
    }, 1000); 
  }) 
})

Related recommendations:

JQuery timer function and countdown function implementation

Three ways to implement user registration countdown function using js and jQuery

JavaScript minute and second countdown timer implementation method

The above is the detailed content of jQuery simulation explosion countdown function technology sharing. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn