dtxzwdl08169 2018-10-26 16:45 采纳率: 0%
浏览 39
已采纳

如何使用java脚本隐藏文本并通过php显示另一个文本和整个java脚本代码触发器?

$_SESSION['MSG']="Incorrect email id and password" is in red color.

After 5 sec it will hide and after that I want to show Try again later in yellow color at same place after 5 sec. $_SESSION['try']="Try again later" but it will not hide until page is not reload or refresh:

<?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 ();
?>
  • 写回答

1条回答 默认 最新

  • douweidao3882 2018-10-26 17:18
    关注

    Try this

    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>';
    }
    

    You use the innerHTML to change the message within the <div></div>.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器