The liveQuery plugin takes care of this work for you.

-----Original Message-----
From: jquery-en@googlegroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Giant Jam Sandwich
Sent: Wednesday, February 06, 2008 3:55 PM
To: jQuery (English)
Subject: [jQuery] Re: on click event does not response


jQuery did not recognize the element ".test" because you had not created it
yet. You have to bind a click to a new element after you create it.
Something like the following:

$("#someID").append("<a href='#'>My Link</
a>").find("a:last").click(function(){
// do something...
});


On Feb 6, 12:46 pm, Jquery lover <[EMAIL PROTECTED]> wrote:
> hi all,
>
> I have problem with my code, when I used jquery to append HTML tags to 
> my list the click event of the new tag did not work, so i decide to 
> move to DOM and the same problem appered again. Here is a snapshot of 
> my code
>
> //does not response !!!
> $(".test").click(function(){
>                                 $("#content").empty();
>                                 return ;
>                         });
>
>                         // creating element
>                         $("a div#textbox").click(function(){
>                                 var list =
document.getElementById("form_list");
>                                 var list_element =
document.createElement("li");
>                                 var link = document.createElement("a");
>                                 $(link).attr("class", "test");
>                                 $(link).attr("href", "#");
>
>                                 var text_val = 
> document.createTextNode("tes tes test");
>
>                                 list_element.append
>
> Child(text_val);
>
>                                 link.appendChild(list_element);
>
>                                 list.appendChild(link);
>
>                                 return false;
>                         });


Reply via email to