Say I have two buttons, like this:
<input type="button" id="button1" value="click me 1" />
<input type="button" id="button2" value="click me 2" />
What would be the difference, besides the code is different, of putting an onclick
attribute on one of them, and using jQuery to handle the other?
HTML:
<input type="button" id="button1" value="click me 1" onclick="alert('Clicked button 1!');"/>
<input type="button" id="button2" value="click me 2" />
JS/jQuery:
$(document).ready(function() {
$("#button2").click(function(){
alert("Clicked button 2!");
});
});