I have this page:
<html>
<head></head>
<body>
<div id="elem"></div>
<button id="addElem">Add Element</button>
<script src="jquery-1.9.1.js" type="text/javascript"></script>
<script type="text/javascript">
$(function () {
//add element to elem div
$("#addElem").click(function () {
$("#elem").append('<a id="test" href="#">this is a test</a><br />');
});
//remove added elements on click event
$("#test").on("click", function(){
alert(12);
});
});
</script>
</body>
</html>
What it is doing, is adding a link and I would like to be able to click on the added link and display an alert message but the alert is not working. What am I missing?