0
我創造了這個函數來顯示一個彈出和關閉一段時間後:jQuery的VAR和隱藏非常快
function alerta(ancho,alto,color,tiempo_s,tiempo,contenido) {
$("#alert_background").show();
$("#alert_window").show(1000);
$("#alert_window").css("width",""+ancho);
$("#alert_window").css("height",""+alto);
$("#alert_window").css("background-color",""+color);
$("#alert_window").append(""+contenido);
if(tiempo!="") {
setTimeout(function() {
$("#alert_background").hide(tiempo);
$("#alert_window").hide(tiempo);
}, tiempo_s);
}
}
alerta("40%","200px","green","4000","3000","<b>Hello World!!!</b>")
我唯一的問題是,在這個函數中:
$("#alert_background").hide(tiempo);
$("#alert_window").hide(tiempo);
的div
關閉非常快,並沒有尊重關閉的時間。我使用setTimeout(function())
,因爲我需要顯示此div一段時間,然後隱藏2 div
。而是在3或4秒內隱藏起來。
時間應是數字,而不是一個字符串。 –
嘗試將int而不是字符串傳入您的'alerta'函數。 'alerta(「40%」,「200px」,「green」,4000,「3000」,「Hello World !!!」)' – zgood
我這樣做,但隱藏時間不尊重 – user2501504