简体   繁体   中英

Open bootstrap modal using Javascript in PHP

I'm trying to open bootstrap modal after login failed, I used the following code:

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

And I incloud jQuery 1.12.4 in HTML head

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

Nothing happen, The LoginFailed modal not showing up !!

I also trying the solution HERE but no luck.

Any help?

See exemple

I tried to tailor the exemple to yours. NOTE: In JSFiddle it will not be accurate since it only runs js css and HTML

You need to use

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

你应该在jquery-1.12.4.js之后包含bootstrap.min.js文件

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM