I dynamically attached a div
element using jQuery on
method, but when i attach a listener to the dynamically updated element it doesn't work?
HTML
<input class="123" type="button" value="button" />
<input class="123" type="button" value="button" />
<div id="footer"></div>
jQuery
$(document).ready(function () {
$('.onlineUsers').on('click', function () {
$('#footer').append("<div class=\"chatboxes\"> <div class=\"close\"><a href=\"#\">x</a></div> </div>");
});
$('a').on('click', function () {
alert("hello");
});
});