views:

42

answers:

3

Hi, my jquery animation is not working, i think the porblem are the dynamic elements.

Is it possible to say live() with animate()?

$(".tls").animate({"left": "-=50px"}, "slow");

kind reagards peter from germany

+1  A: 

LiveQuery is pretty good for dealing with dynamic elements.

http://docs.jquery.com/Plugins/livequery

Māris Kiseļovs
+1  A: 

I assume you have some kind of trigger for the animation?

The code line you supplied will run the animation whenever the code line is reached in the code - what it seems you want, is to bind an animation to an element, and execute it later.

Try, for example,

$('.tls').live('click', function(ev) { 
    $(this).animate({left: '-=50px'}, 'slow'}); 
    // Add any necessary event handling here, for example
    ev.preventDefault();
    ev.stopPropagation();
});
Tomas Lycken
A: 

How are you making the live call? Maybe you should use delegate instead: http://api.jquery.com/delegate/

alcuadrado