为了账号安全,请及时绑定邮箱和手机立即绑定

如何确定一个按钮关闭哪一个警告框呢??用JS来触发的话

如何确定一个按钮关闭哪一个警告框呢??用JS来触发的话,给按钮绑定了事件,却没有绑定哪一个警告框。。。。

正在回答

3 回答

<div class="alert alert-warning" role="alert" id="myAlert">
    <h4>谨防被骗</h4>
    <p>请确认您转账的信息是你的亲朋好友,不要轻意相信不认识的人...</p>
    <button type="button"  class="btnbtn-danger" id="close">关闭</button>
</div>
<div class="alert alert-warning" role="alert" id="myAlert1">
    <h4>谨防被骗</h4>
    <p>1请确认您转账的信息是你的亲朋好友,不要轻意相信不认识的人...</p>
    <button type="button"  class="btnbtn-danger" id="close1">关闭</button>
</div>
  <script src="http://libs.baidu.com/jquery/1.9.0/jquery.js"></script>
  <script src="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
  <script>
     $(function(){
            $("#close").on("click",function(){
                $(this).alert("close");
            });
            $("#close1").on("click",function(){
                $(this).alert("close");
            });
          });
  </script>
0 回复 有任何疑惑可以回复我~
#1

null__ 提问者

非常感谢!
2016-06-01 回复 有任何疑惑可以回复我~

并没有用。。。

<body>

<div class="alert alert-warning" role="alert" id="myAlert1">

    <h4>谨防被骗</h4>

    <p>请...</p>

    <button type="button"  class="btn btn-danger" id="close1">关闭</button>

</div>

    <div class="alert alert-warning" role="alert" id="myAlert2">

    <h4>谨防被骗</h4>

    <p>请...</p>

    <button type="button"  class="btn btn-danger" id="close2">关闭</button>

</div>  

  <script src="http://libs.baidu.com/jquery/1.9.0/jquery.js"></script>

  <script src="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>

  <script>

    $(function(){

        $("#close1").on("click",function(){

            $(this).alert("close");  

        });       

        $("#close2").on("click",function(){

            $(this).alert("close");  

        }); 

});

  </script>

点击两个按钮都是关闭第二个警告框。。。


0 回复 有任何疑惑可以回复我~
#1

陈微语

这样写是对的,你把两个警告框的内容弄成不一样的先吧
2016-04-25 回复 有任何疑惑可以回复我~
#2

西风潇潇

有用的,因为你的2个警告框内容是一模一样的,所以点击的时候会造成视觉上的错觉,认为关闭的是同一个按钮,其实关闭的是不同的。 随便修改下某一个警告框的内容,就可以发现。
2016-06-11 回复 有任何疑惑可以回复我~
#3

null__ 提问者 回复 西风潇潇

666,是的,谢谢了!
2016-06-13 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消

如何确定一个按钮关闭哪一个警告框呢??用JS来触发的话

我要回答 关注问题
意见反馈 帮助中心 APP下载
官方微信