I can't understand why I can't.



  • <button onclick="abbr();">Нажми меня для запуска</button>
    <p id="example"></p>
    <script>
      function abbr() {
        let a = 0;
        let timerId = setTimeout(Seconds, 1000, a);
      }
    

    function Seconds(a) {
    let t = document.getElementById("example");
    t.innerHTML = a;
    a += 1;
    if (a > 4) {
    window.close();
    }
    return a;
    }
    </script>



  • function abbr() {
      let a = 0;
      let timerId = setTimeout(Seconds, 1000, a);
    }
    function Seconds(a) {
      let t = document.getElementById("example");
      t.innerHTML = a;
      a += 1;
      if(a > 4) { window.close(); }
      return a;   
    }
    <button onclick="abbr();">Нажми меня для запуска</button>
    <p id="example"></p>

    What's wrong?

    By goodness, your violin should be declared to the element in which it is used.

    It is therefore necessary to cause/describe the required functions after the entire page is downloaded (onLoad)



Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2