I need JS onclick event but it works very strange for me and I can't figure out why. There're three examples below and I don't understand why the first one doesn't.
/ First
$(document).ready(function () {
$("button#clear-id").click(function(){      // this one doesn't work
    alert('Howdy');
});
...
/ Second
$(document).ready(function () {
$("body").click(function(){      // this one works
    alert('Howdy');
});
...
/ Third
$(document).ready(function () {
$(document).on('click', '#clear-id', function () {    // this one works
  alert("Hello!");
});
...
/ HTML of the button looks like
<button type="button" class="close" id="clear-id" aria-label="Close" value="';   the_ID(); echo'">
    <span aria-hidden="true">×</span>
</button>
 
     
    