0

下一个代码用于在用户注册时显示弹出模式,但它会使我的下一个代码崩溃。我怎样才能覆盖这个?

          if($('.alert').html().indexOf('Welcome! You have signed up successfully.') != -1) 
          $('#congrats').show();

应该显示细节的其他部分不再显示。

      $(".sub a").click(function() {
    $(this).siblings("div").show("fast");
      });

视图代码:

 <div class="sub">   
<%= link_to(image_tag("/images/caret-horizontal.png", id: "caret-horizontal"), '#') %>
<h3>
 <%= website.name  %>
</h3>


<div class="desc">
  <p> <%= website.url %> </p>
  <p> <%= website.category %> </p>
  <p> <%= website.language %> </p>
</div>

来自 Chrome 控制台的错误:

     Uncaught TypeError: Cannot call method 'indexOf' of null 

好人(Rob W)对此表示:

 The error is caused by the fact that .html() returns null when the jQuery collection consists of zero DOM elements.

我的通知/警报的 HTML:

      <div class="alert alert-notice">Signed out successfully.</div>
4

0 回答 0