如何销毁活动挂钟,使其在倒数到0后再也不会重启?

时间:2019-04-11 09:57:08

标签: javascript return destroy flipclock

我的倒数计时时钟显示下一部Marvel电影发行之前需要多长时间。但是,我不能销毁0之后的时钟,而是显示一个负数。

我尝试使用onDestroy,但是它破坏了我所有的倒计时时钟。我尝试使用return,尽管它也不起作用。

/*Countdown until Captain Marvel Release */
var next_show = new Date('2019-04-11T10:48:00');
var diff = next_show.getTime() - new Date().getTime();

var showtime = Math.floor(diff/1000);
var clock = $('#clock3').FlipClock({
    clockFace: 'DailyCounter',
    countdown: true,
    callbacks: {
      stop: function () {
        $("#clock3").fadeOut(1000);
        $("#myButton3Show").fadeOut(1000);
        $("#myButton3Hide").fadeIn(1000);
        if(diff==0) { 
          return; //stop the execution of function
      }
      }
    }
});
                        <div class="captainmarvel2" style="width: 30%">
                            <img src="Pictures/captainlogo.png">
                            <h5>In Theaters 8 March 2019</h5>
                            <div id="clock3"></div>
                            <a href="https://www.marvel.com/movies/captain-marvel" target="_blank"
                                id="myButton3Show">About Movie</a>
                            <a href="https://www.myvue.com/film/captain-marvel" target="_blank" id="myButton3Hide"
                                style="display: none">Buy
                                Ticket on Vue</a>
                        </div>

What I want is that when the countdown reaches 0, another button is shown, and the countdown and old button is hidden - forever. I have used jquery fade in and fade out for that. However, updating the website window brings the clock back on negative values.

The website is student.city.ac.uk/~aczc972

0 个答案:

没有答案