Important: if you are creating a new object with jQuery and binding an event, you MUST use prop and not attr, like this:
$("",{ id: "yourId", class: "yourClass", html: "" }).on("click", function(e) { alert($(this).prop("id")); }).appendTo("#something");