You will need to use live
$('a.popupExit').live("click", function() { $('#lightbox').css("display", "none"); return false; }); dreame4 wrote:
Hi, I have such a piece of code: $('body').prepend('<div id="lightbox"><div class="lb-display"><div class="lb-bg"><div class="header no-bg sid"><h2 class="header">Embed Code</h2><a href="#" class="popupExit">exit</a></div></div></div></ div>'); Then I would like to add a click event to a.popupExit but it doesn't work correctly. I'm doing it in this way: $('a.popupExit').click(function() { $('#lightbox').css("display", "none"); return false; }); Anyone can give me some clue how to do it right? With regards, Adam