I added click event to button . it is working fine.
$("#button1").click(function(){var elem = $("<p></p>").text("hello").attr("id","created");
$("body").append(elem);});
$("#button2").click(function(){ $("#created").hide();});
https://jsfiddle.net/e89uf3wg/5/
But adding click event to new created element not working.
$("#button1").click(function(){var elem = $("<p></p>").text("hello").attr("id","created");
$("body").append(elem);});
$("#created").click(function(){ $("#created").hide();});
https://jsfiddle.net/e89uf3wg/19/
Can someone explain. i am expecting. I create only one element and when i click on that element it should hide. thats it. This question is not about id and class . just create one element and try to experiment what i am saying. I want when i click on created paragraph it should hide itself.