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???"

HJW
  • 1,012
  • 2
  • 13
  • 32
  • 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 Jul 26 '17 at 03:19

0 Answers0