During the running of my website i create new divs using jquery with class \"a\". I have defined a click() function for \"a\" class as follows:
$(document).r
Use the "live" method.
http://api.jquery.com/live/
Try using the .live() function which should also apply for newly inserted DOM elements that match your selector:
$(document).ready(function() {
$(".a").live('click', function(){
$(".a").hide();
});
});
This might also work.
(function($) {
$(document).ready(function () {
$('body').on('click', '.a', function() {
$(this).hide();
});
});
}( jQuery ));
.on() attaches events to controls that are both present and not yet present.
$(document).delegate('.a', 'click', function() {
$(this).hide();
});