单击按钮时,警报第二次不起作用 [英] Alert is not working second time when clicking on button

查看:129
本文介绍了单击按钮时,警报第二次不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是引导程序版本,因此我创建了一个类似于以下示例的下拉菜单.

I am using bootstrap version so I have created a slide down menu same like below example.

按钮第二次不起作用

<div class="alert alert-success" id="success-alert">
<button type="button" class="close" data-dismiss="alert">x</button>
<strong>Success! </strong>
Product have added to your wishlist.

问题是,当我单击向下滑动中的关闭"按钮时,栏正在关闭.

The problem is that when I click on close button in slide down the bar is closing up.

但是当我再次单击添加愿望列表时,向下滑动不再出现.

But when I again click on add wish list the slide down is not appearing again.

我的问题不仅仅是关闭.当我单击"x"按钮时,它应该关闭;否则,它应在特定时间后自动关闭.

My problem is not only closing. It should close when i click on 'x' button if not it should close automatically after specific time.

谢谢.

推荐答案

不是编写完整的代码.我使用了Jquery的slideUp() dealy()slideDown()方法.

Instead of writing whole code .I used slideUp() dealy() and slideDown() methods of Jquery.

$(document).ready(function() {
  $("#success-alert").hide();
  $("#btn2").click(function showAlert() {
    $("#success-alert").slideDown(300).delay(2000).slideUp(400);
  });
});

$('#success-alert .close').click(function() {
  $(this).parent().hide();
});

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="product-options">
  <input type="button" id="btn2" value="Add to wish list" />
</div>
<div class="alert alert-success" id="success-alert">
  <button type="button" class="close" aria-label="Close">
                <span aria-hidden="true">&times;</span>
            </button>
  <strong>Success! </strong> Product have added to your wishlist.
</div>

这篇关于单击按钮时,警报第二次不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆