如果 loginStatus == false,我想使用 jQuery 在搜索单击时弹出登录模式。
即如果用户未登录,我希望他先登录。
$('#serviceSelect').on('click', function(event) {
if (found == 0) {
alert("Sorry donot exist")
}
if(found ==1)
{
var status=sessionStorage.getItem('isLoggedIn');
//alert(status);
if(status==true){
alert("Logged in");
/*-------------- Specify the Questionnare link here -------------*/
}
else{
alert("Logged out");
/*$('#serviceSelect').attr('data-target','#login-modal');*/
var modal = $("#login-modal");
modal.style.display = "block";
}
}
});
如果用户想自己登录,这是弹出登录的列表项。
<li class="sidebar-brand" id="loginref"><a href="#"
data-toggle="modal" data-target="#login-modal"
data-backdrop="static">
登录模态div:
<div class="modal fade" id="login-modal" tabindex="-1" role="dialog"
aria-labelledby="myModalLabel" aria-hidden="true"
style="display: none;">
更新:
这是弹出模态框,但是模态框的js没有附加在模态框上。
即,有一个在登录模式下执行的login.js。 通过使用此弹出模式,该 js 不会被执行。
modal.modal('show');
最佳答案
试试这个代码
$('#login-modal').modal('show');
关于javascript - 使用 jQuery 弹出模态框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39503716/