I want to be able to click on a element I've dynamically created and create an alert, and I can't seem to figure it out. I've looked at a bunch of similar threads on how to use .on, but I can only get it to work for static elements. Thanks in advance!
<span id="about">About</span>
<div id="lhn"></div>
And JavaScript:
$(document).ready(function () {
$("#about").click(function () {
$("#lhn").append("<div id='#child'>Child</div>");
$("#lhn").on("click", "#child", function () {
alert("Child has been clicked");
});
});
});