jQuery的自动褪色 [英] Jquery auto-fading
问题描述
我通过AJAX推页面上的一些元素。我怎样才能让他们自己创建后disapear 3秒,对于为例带有淡出效果?
的HTML是推动通过执行多个上传的外部jQuery库(的http:// blueimp。 github.com/jQuery-File-Upload/ )。后一个文件上传插件拉这个页面上:
< DIV CLASS =模板下载变脸>
文件名 ...
错误...
< / DIV>
使用插件的回调函数。例如:
$('#文件上传)。绑定(fileuploadalways',功能(即数据){
的setTimeout(函数(){$('div.template-download.fade)淡出()},3000);
});
...应触发淡出的元素,无论什么样的结果是3000毫秒的AJAX回来后,。
回调是必不可少的任何类型的AJAX功能。通常情况下你的code不断尽可能快地运行,而无需等待您的AJAX函数或方法返回的任何数据。回调只是运行后,它会返回一个结果,而具体回调可要求具体的结果。
其他的回调只为成功上传的存在,上传失败等阅读的https: //github.com/blueimp/jQuery-File-Upload/wiki/Options 和向下滚动到回拨选项。
I have some elements pushed on the page via ajax. How can I make them disapear 3 seconds after their creation, for exemple with a fade-out effect ?
The html is pushed by an external jQuery library performing multiple upload ( http://blueimp.github.com/jQuery-File-Upload/ ). After a file is uploaded, the plugin pulls this on the page:
<div class="template-download fade">
FileName ...
Errors...
</div>
Use the plugin's callback functions. For instance:
$('#fileupload').bind('fileuploadalways', function (e, data) {
setTimeout(function(){$('div.template-download.fade').fadeOut()}, 3000);
});
...should trigger a fadeOut on the element 3000 milliseconds after your AJAX return, regardless of what the result was.
Callbacks are essential to any kind of AJAX functionality. Normally your code keeps on running as quickly as possible, without waiting for your AJAX function or method to return any data. The callback is only run after it returns a result, and specific callbacks can be called for specific results.
Other callbacks exist only for successful uploads, failed uploads, etc. Read https://github.com/blueimp/jQuery-File-Upload/wiki/Options and scroll down to "callback options."
这篇关于jQuery的自动褪色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!