I'm rather new to jQuery but i want to know what the best practice is when making a button do something.
Should i use .click()
HTML
<button id="submit" class="btn btn-default">Submit</button>
JS
$('#submit').click(function(){
//DO SOMETHING
});
Or call a function
HTML
<button class="btn btn-default" onclick="Submit();">Submit</button>
JS
function Submit() {
//DO SOMETHING
}
My question is, do these two methods behave the same way? If not, what are the advantages of one over the other.
*I've tried and seems to work the same way but being new to jQuery i wanted to make sure.