The event is being bound to the button elements before button#1122 is being
added to the DOM. Try this:

$('button').live('click',function(event){
       event.preventDefault();
       var id = $(this).attr('id');
       console.log("this id " + id);
});

The live() function binds the event to all of the elements that meet the
criteria, but those in the DOM on $(document).ready() and those created in
the future.

For future reference, jQuery help questions like this should be asked in the
jquery-en group, this group is for discussion of the development of jQuery
itself. See http://groups.google.com/group/jquery-en

Chuck Harmston
http://chuckharmston.com


On Tue, Apr 14, 2009 at 2:51 PM, shuttlesworth <[email protected]> wrote:

>
> Hi,
>
> I have implemented the following code:
>
>  $(lastElement).after('<button type="button" id="1122">Uninvite</
> button>');
>
> $("button").click(function()
>  {
>        var id = $(this).attr('id');
>        console.log("this id " + id);
>  }
>
> I see the button being displayed on the page but the problem occurs
> when I click the Uninvite button as it is not invoking the click
> function. Does anybody know what I am doing wrong or can give me any
> pointers to resolve this issue?
>
> Best Regards,
>
> ShuttlesWorth
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"jQuery Development" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/jquery-dev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to