1

I always use jquery event like:

$(element).on('click', function() {
    DoSomething();
});

But other way is exists - add "onclick" attribute to html element:

<button onclick="DoSomething()"></button>

Which way is better and why?

AlexAstanin
  • 343
  • 1
  • 4
  • 14

1 Answers1

1

It is best to use the jquery because you want to separate your layout, functionality, and styling for easier readability and editing.

Gary Hayes
  • 1,728
  • 1
  • 15
  • 23