0
我如何使div #eFileStatus和#sFileStatus slideDown然後等待5秒和slideUp,這是我的功能,當前工作並在5秒後滑動。jQuery slideDown()5秒後隱藏和滑動後
function changeShare(addr)
{
var conf = confirm("Changing the share url will cause the previous URL to not be accessible\nAre you sure?");
if(conf == true)
{
// ajax request to change share url, create div after #key containing status message
$.post("/var/jq/ajaxrequest.php", { changeShare: addr },
function(data){
$('#key').after('<div id="'+data.returnValue[0]+'FileStatus">'+data.returnValue[1]+'</div>');
}, "json");
// reload data in #key with new share url
$("#key").load(window.location.pathname+" #key > *");
// slideup the status message div
setTimeout(function(){
$('#eFileStatus').slideUp();
$('#sFileStatus').slideUp();
}, 5000);
}
}
我曾嘗試:
$("#eFileStatus, #sFileStatus").hide().slideDown(function(){
setTimeout(function(){
$('#eFileStatus').slideUp();
$('#sFileStatus').slideUp();
}, 5000);
});
但這並不滑下,同時也停止了向上滑動。
爲什麼需要hide()在這裏? –
你檢查了瀏覽器的控制檯是否有任何錯誤?你的代碼應該可以正常工作:http://jsfiddle.net/koala_dev/fWZyT/雖然更好的方法是使用'delay()' –
@ eicto因爲'slideDown()'動畫不需要隱藏元素, t對可見元素採取行動 –