下一个代码用于在用户sign_up时显示弹出模式,但它会崩溃我的下一个代码。我怎么能覆盖这个?
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>