Skip to content

Instantly share code, notes, and snippets.

@javanigus
Created December 11, 2017 23:30
Show Gist options
  • Save javanigus/172aa54a48c18c1b6e04d8bfb35f78bd to your computer and use it in GitHub Desktop.
Save javanigus/172aa54a48c18c1b6e04d8bfb35f78bd to your computer and use it in GitHub Desktop.
jQuery handle event of dynamically-created element
$("body").append("<div class='a'></div>");
$(document).on("click", "div.a", function (event) {
// do something when the div is clicked
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment