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?
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?
It is best to use the jquery because you want to separate your layout, functionality, and styling for easier readability and editing.