You have run into a fairly common issue: how to get events to work with elements that are added to the DOM, through either ajax or simple DOM mainpulation, after the "document ready" code has already fired.

This FAQ topic should answer your question:

http://docs.jquery.com/Frequently_Asked_Questions#Why_do_my_events_stop_working_after_an_Ajax_request.3F

If you still have problems after reading through it and trying one of the many solutions, let us know.

--Karl

____________
Karl Swedberg
www.englishrules.com
www.learningjquery.com




On Aug 22, 2008, at 2:44 PM, SHiDi wrote:


Hi all.

I've tried to reload a content using jQuery.post. However, it seems
that once the content is reloaded, the script didn't work the way it
supposed to.

My jQuery script is:

   $(".click").click(function() {
       alert('Hello World');

       $.post('actions.php',
        {},
        function(data) {
            $("#new").html(data);
        });
   });

Content for actions.php:

echo '<a href="#" class="click">Click Me Again</a>';

As for the HTML:

<div id="new">
 <a href="#" class="click">Click Me</a>
</div>

On first click, the script will work. But once the content reloaded,
it's no longer work. Any idea why?

Thanks in advanced :)

Reply via email to