2

noob question here (beginner to JavaScript & jQuery). I am learning code via codecademy etc., and they are teaching to use the following:

$('.projects-button').on('click', function() {
 $('.projects').show();
  });

Then, while researching something on Stack, I found the following:

$('.projects-button').click(function() {
 $('.projects').show(); 
  });

Is there a difference between "on click function," and "click function???"

1
  • Essenitally equivalent. The second version is a shortcut for the first. The first form is useful especially when you want to use event delegation.
    – RichGoldMD
    Commented Jul 26, 2017 at 3:19

0

Browse other questions tagged or ask your own question.