JQuery does not work. I can not connect it. And I do not understand what could be the problem. After all, the files are connected in the correct order. And the paths are correct.

<script type="text/javascript" src="jquery-3.3.1.min.js"></script> <script type="text/javascript"> alert("Hello!"); </script> 

Normal js script type alert triggered. alert

But when trying to use the library does not respond

 <script type="text/javascript"> $(.block).on('click', function(event) { event.preventDefault(); alert("Hello"); });; </script> 

Nothing happens per click

  • one
    Before using the library, read at least a little syntax: ( - humster_spb
  • rude you, why not just point out the mistake - GENESIS
  • @GENESIS, because the answer has already been given - humster_spb

1 answer 1

The error is that when you specify a class you need to put quotes)

  $('.block').on('click', function() { alert("Hello"); }); 
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div class="block">Кнопка</div>