My guess is that when you dynamically create a new button, the click
event handler won't be bound to it. So if you use livequery plugin, it
may work. Something like this:

$(function(){
        $(".removeButtonClass").livequery('click', function() {
                alert("handler worked");
        })

})

On Nov 5, 6:38 pm, Slantedview <[EMAIL PROTECTED]> wrote:
> I'm using javascript and Jquery to dynamically create an input button
> and attempt to respond to a click even for that button. Unfortunately,
> I can't get the click handler to work. I am creating the button like
> this:
>
> var removeButton = document.createElement("INPUT");
> removeButton.type = "button";
> removeButton.value = "Remove";
> $(removeButton).addClass("removeButtonClass");
> $("myDiv").append(removeButton);
>
> My event handler looks like this:
>
> $(function(){
>         $(".removeButtonClass").click(function() {
>                 alert("handler worked");
>         })
>
> })
>
> In Firebug, I can see that the new input button is being successfully
> created and the removeButtonClass is successfully being set, but when
> I click the button the event handler is never called. What am I
> missing?
>
> Regards,
> Jonathan

Reply via email to