$_SESSION['MSG']="Incorrect email id and password"
是红色的。
5秒后它将隐藏,之后我想在5秒后在相同的地方以黄色显示重试。$_SESSION['try']="Try again later"
,但它不会隐藏,直到页面不重新加载或刷新:
<?php
session_start();
if(isset($_SESSION['MSG'])){
echo '<div id="incorrect">' . $_SESSION['MSG'] . '</div><script
type="text/javascript">
function showIt() {
document.getElementById("incorrect").style.visibility = "hidden";
}
setTimeout("showIt()", 5000);
</script>';
}
unset ($_SESSION['MSG']);
session_destroy ();
?>
发布于 2018-10-27 01:18:10
尝尝这个
if(isset($_SESSION['MSG'])){
echo '<div id="incorrect">'.$_SESSION['MSG'].'</div><script type="text/javascript">
document.getElementById("incorrect").style.cssText = "background: red";
function showIt() {
document.getElementById("incorrect").style.visibility = "hidden";
}
setTimeout("showIt()", 5000);
function showIt() {
document.getElementById("incorrect").style.cssText = "background: yellow";
document.getElementById("incorrect").style.visibility = "visible";
document.getElementById("incorrect").innerHTML = "'.$_SESSION["try"].'";
}
</script>';
}
您可以使用innerHTML
在<div></div>
中更改消息。
https://stackoverflow.com/questions/53013145
复制相似问题