I want to add a onclick event to a div which generated using folowing code:
$("<div />").attr("city", $(this).attr("city"))
.attr("state", $(this).attr("state"))
.html($(this).attr("city") + ',' + $(this).attr("state"))
.appendTo($('#cityList'));
Should I write onlick event in html()?
Why not split up the creation of the div and the chaining of the rest of the code. For example