Jquery add timer


< html lang= "en" >
< head >

<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel="stylesheet" href="css/main1.css">
<title></title>
<script src="js/jquery-1.12.4.min.js"></script>
<script >
    /*
    :
    1"" 
    20
    3"X" 

    */
    $(function () { 
        var $pop_main = $(".pop_main");
        var $pop_con = $(".pop_con");
        var iTop = $pop_con.css("top");
        var $oCount = $("count");
        var $oShut = $("shutoff");
        var $timer = null;

    $("-sharpbtn").click(function () { 
        $pop_main.show();
        $pop_con.css({"opacity":0,"top":0});
        $pop_con.animate({"opacity":1,"top":iTop});
    });
    
    

    
   
    $(".pop_title a").click(function () { 
        $pop_con.animate({"opacity":0,"top":0},function(){
        $pop_main.hide();
        });
    })
 })

</script>

< / head >
< body >

<input type="button" value="" id="btn">
<div class="pop_main" id="pop_main">
  
    <div class="pop_con">
        <div class="pop_title">
            <h3></h3>
            <a href="-sharp" id="shutoff"></a>

        </div>
        <div class="pop_detail">
            <p class="pop_text">

</div> <div class="pop_footer"> <span id="count">5</span> </div> </div> <div class="mask"></div> </div>

< / body >
< / html >

Feb.21,2022

 $(function () {
      var $pop_main = $('.pop_main');
      var $oCount = $('-sharpcount');
      var $timer = null;
      $('-sharpbtn').click(function () {
        var $time = 5;
        $pop_main.show();
        $timer = setInterval(function () {
          if ($time == -1) {
            clearInterval($timer);
            $timer = null;
            $pop_main.hide();
          }
          $oCount.html($time);
          $time--;
        }, 1000);
      });
      $('.pop_title a').click(function () {
        $pop_main.hide();
        clearInterval($timer);
      })
    })
Menu