使用 live() 触发 jQuery 动画
我有一个 jQuery 动画无法正常工作。我认为问题来自于动态元素部分。
是否可以使用 animate()
调用 live()
方法?
这是我到目前为止所做的:
$(".tls").animate({"left": "-=50px"}, "slow");
I have a jQuery animation that is not working. I think the porblem comes from the parts that are the dynamic elements.
Is it possible to call the live()
method with animate()
?
Here's what I've go so far:
$(".tls").animate({"left": "-=50px"}, "slow");
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我假设你有某种动画触发器?
您提供的代码行将在代码中到达该代码行时运行动画 - 您似乎想要的是将动画绑定到元素,然后稍后执行它。
尝试,例如,
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,
LiveQuery 非常适合处理动态元素。
http://docs.jquery.com/Plugins/livequery
LiveQuery is pretty good for dealing with dynamic elements.
http://docs.jquery.com/Plugins/livequery
你如何进行实时通话?也许你应该使用委托: http://api.jquery.com/delegate/
How are you making the live call? Maybe you should use delegate instead: http://api.jquery.com/delegate/
有同样的问题。需要在没有触发器的情况下进行实时和动画处理。我写了一些解决办法。我用递归函数修复了它。这是我的例子:
希望我能帮忙。
Had the same problem. Needed live and animate without an trigger. I wrote a little work around. I fixed it with a recursive function. Here is my example:
Hope I could help.