在PHP中使用Javascript打开引导程序模式

时间:2019-06-10 10:48:14

标签: javascript php twitter-bootstrap bootstrap-4 bootstrap-modal

登录失败后,我试图打开引导程序模式,我使用了以下代码:

if (mysqli_num_rows($query) != 0)
{
    // Login successfully
}
else
{ 
    //Login failed
    echo '<script type="text/javascript"> $("#LoginFailed").modal("show")</script>';
} 

我在HTML头中使用incloud jQuery 1.12.4

<script src="js/jquery-1.12.4.js"></script>

什么也没有发生,LoginFailed模态没有显示!

我也尝试了解决方法HERE,但是没有运气。

有帮助吗?

2 个答案:

答案 0 :(得分:1)

See exemple

我试图为您量身定制示例。 注意:在JSFiddle中,由于它仅运行js css和HTML

,因此并不准确。

您需要使用

jQuery (document) .ready (function (e) {
    // Your Modal
}

答案 1 :(得分:0)

您应在bootstrap.min.js之后添加jquery-1.12.4.js文件