Показать сообщение отдельно
  #4 (permalink)  
Старый 11.04.2016, 11:22
Аватар для рони
Профессор
Отправить личное сообщение для рони Посмотреть профиль Найти все сообщения от рони
 
Регистрация: 27.05.2010
Сообщений: 33,103

woojin,
<div id="timer"></div>
 <script>
 var answerTimer = {
    timerAnswer: 0,
    answerTimerId: null,
    timer: function () {
        this.toPrint();
        ++this.timerAnswer;
        var self = this;
        this.answerTimerId = setTimeout(function() {
        self.timer()
}, 1000);
    },
    reset: function () {
        this.timerAnswer = 0;
    },
    stop: function () {
        this.reset();
        clearTimeout(this.answerTimerId);
    },
    toPrint: function () {
        document.getElementById("timer").innerHTML = "last answer: " + this.timerAnswer + " sec";
    }
};
  answerTimer.timer();
  setTimeout(function() {
        answerTimer.stop()
}, 5054);

  </script>
Ответить с цитированием