Laurent Goussard schrieb:
> I'm trying a very simple (in my opinion) use of jQuery, but I can't
> figure how I am suppose to make it work.
> Can someone explain me how enabling the click event on .test even if
> the .test element is loaded dynamically from script (ajax doesn't work
> neither) ?
The correct approach is to apply the click handler after the element has 
been added to the DOM. In your example, $(".test") finds nothing. Try this:

$("#trigger").click(function(){
        $("#content").append('<div class="test">click does not work</div>');
        $(".test").click(function(){
                alert("yeepee");
        });
        return false;
});

Or even this:

$("#trigger").click(function(){
        $("#content").append('<div class="test">click does not work</div>') // 
no ; here
        .find(".test").click(function(){
                alert("yeepee");
        });
        return false;
});

-- 
Jörn Zaefferer

http://bassistance.de


_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/

Reply via email to