Skip to content

Instantly share code, notes, and snippets.

@kingluddite
Created May 15, 2020 22:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kingluddite/0b4cf305aac05aa1eebb857270370ba0 to your computer and use it in GitHub Desktop.
Save kingluddite/0b4cf305aac05aa1eebb857270370ba0 to your computer and use it in GitHub Desktop.
dynamic jquery elements
$(document).ready(function() {
console.log("click code works!");
var root = document.querySelector("#empty-area");
root.innerHTML =
"<button id='name-btn'>Click to see my name</button><div id='name'></div>";
$("#empty-area").on("click", "#name-btn", function() {
console.log("test");
$("#name").html("John Jacob Jingleheimer-Schmidt");
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment