Как я могу сделать div #eFileStatus и #sFileStatus slideDown, а затем ждать 5 секунд и slideUp, это моя функция, которая в настоящее время работает и сползает через 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);
});
но это не скатывается вниз, и оно также останавливает скользящее движение вверх.
Хорошо, я нашел решение, так как вы можете видеть, что я поместил slideDown внутри функции ajax, поэтому он ждет создания div, прежде чем пытаться свернуть.
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>');
// reload data in #key with new share url
$("#key").load(window.location.pathname+" #key > *");
// slideup the status message div
$("#eFileStatus, #sFileStatus").hide().slideDown().delay(5000).slideUp();
}, "json");
}
}