javascript – Doesn't want to handle jquery events

Question:

jquery doesn't want to handle events. I can't figure out what the problem is.


$('#mybutton').click(function() {
  alert('Вы нажали на элемент "button"');
});

$('#mybutton').click();
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<button id="mybutton">Кнопка</button>

Doesn't react to the click event of the #mybutton element

Links, links are spelled out everywhere. But it reacts to the $ (window) .scroll event.

What could be?

Answer:

 $(document).ready(function(){
      $('#mybutton').click(function() {
        alert('Вы нажали на элемент "button"');
      });
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<button id="mybutton">Кнопка</button>
Scroll to Top