Skip to content

Instantly share code, notes, and snippets.

@aestrro
Created October 2, 2015 18:33
Show Gist options
  • Save aestrro/cceb2d146ab7548958aa to your computer and use it in GitHub Desktop.
Save aestrro/cceb2d146ab7548958aa to your computer and use it in GitHub Desktop.
Triggering Elements after DOM loaded
// Append anchor tag after DOM load
$('.container').append("\
<a href='#' class='someclass'>Give me a cookie?</a>\
")
// Attach click event to .someclass, et voilà
$(document).on("click",".someclass" ,function(e){
e.preventDefault();
console.log("ayyyyy!");
});
// ayyyyy!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment