When generating HTML from server, for example, via echo
in PHP, is it better to assign events:
<div>
<input type="button" onclick="Click(123)"/>
</div>
function Click(x)
{
var id = x;
//Do Ajax Call
}
Or to declare events in JQuery/JavaScript...
<div id="123">
<input type="button" class="myButton"/>
</div>
$(".myButton").click(function(){
//Fetch the ID as well
var parentID = $(this).parent('div').attr('id');
//Then do an Ajax Call
});
Which is the best practice?