可以让 jquery.live() 与负载一起工作吗?
我无法使 $.live() 与“load”事件一起使用,例如:
$(".animate").live("load", function(){
$(this).hide().fadeIn(1000);
})
详细信息:
我有一个包含 ajax 结果的页面。在这些 ajax 中,我可以看到许多带有“animate”类的错误消息。所以,我希望每次浏览器加载带有“animate”类的元素时,浏览器都会使用 fadeIn 对其进行动画处理。
有可能吗?
I can't make $.live() work with "load" event, like:
$(".animate").live("load", function(){
$(this).hide().fadeIn(1000);
})
Details:
I have a page with ajax results. In these ajax I can have many error messages with class "animate". So, I want every time the browser loads a element with "animate" class, browser animates it, usind fadeIn.
It's possible?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你可以使用 .ajaxComplete()
每当Ajax 请求完成,jQuery 触发 ajaxComplete 事件。此时将执行已使用
.ajaxComplete()
方法注册的任何和所有处理程序。只是一个提示: 也许将其与 < strong>.ajaxSend()
每当 Ajax 请求即将发送时, jQuery 触发ajaxSend 事件。此时将执行已使用
.ajaxSend()
方法注册的所有处理程序。you could do it with the .ajaxComplete()
Whenever an Ajax request completes, jQuery triggers the ajaxComplete event. Any and all handlers that have been registered with the
.ajaxComplete()
method are executed at this time.just-a-tip: perhaps combine it with .ajaxSend()
Whenever an Ajax request is about to be sent, jQuery triggers the ajaxSend event. Any and all handlers that have been registered with the
.ajaxSend()
method are executed at this time.您可以确保该元素在发送到浏览器之前是隐藏的(通过 css)。然后,可以使用 setTimeout(...) 循环来查找隐藏的内容并开始动画。
You could make sure the element is hidden (via css) before it is sent to the browser. Then, a setTimeout(...) loop could be used to find those which are hidden and begin the animation.