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

Probably your code runs first $("div#add_comments").click( ... then it insert the new html. So when $("div#add_comments").click runs, there is nothing to be bound.
Then the new html is inserted and is not modified.

Olivier

Tahir wrote:
i have this problem when i call a function onClick after
insertBefore();

when i click a button it insert TEXT AREA, SEND BUTTON at right place.
and then at that i apply some functionality like ALERT("ABC");  at
that inserted BUTTON and it does not work.
Help me out of this ... plz soon.

***** Code is OK if i does not put it in this snario. Only when i
dynamically insert some tage and apply an event to those it does not
work ****


--------------  OK (it inserts at relevant position)
------------------

$("div#sec_news_comments_stats").click(function () {

        $("<div id='sec_news_comments'><textarea name='comments' rows='7'
cols='70'></textarea><div id='add_comments'>Save Comments</div></
div>").insertBefore($(this).parent()).hide();
        $("div#sec_news_comments").slideDown("slow");

        }

---------         Problem ()   -------------------

$("div#add_comments").click(function(){
                alert("Hello add_comments");    // Some functionality but it 
did not
even gave alert.
        });


Reply via email to