无法调用显示条件的模态



我想在条件下调用congats Bootstrap modal:当显示一些通知文本时调用show modal。

条件正确。我尝试了简单的提醒,一切都很好。

这是我的代码:

   if ( $('.alert').text() == 'Signed in successfully.' ) {
 $('#congrats').show();
    }

这是我的html:

<div class="modal fade hide" id="congrats">

浏览器控制台中没有错误。

我做错了什么?

我认为$(".aalert").text()中可能包含一些空格,所以请尝试jquery trim并使用以下

if ($.trim($('.alert').text()) == 'Signed in successfully.') {
  $('#congrats').show(); // or $('#congrats').model("show"); as per the recent comment
}

祝你好运!!

对不起,由于某种原因,我发现语法发生了变化或我错过了它

  if ( $('.alert').text() == 'Signed in successfully.' ) {
    $('#congrats').modal('show')
   }

最新更新