本站消息

站长简介/公众号

  出租广告位,需要合作请联系站长


+关注
已关注

分类  

暂无分类

标签  

暂无标签

日期归档  

暂无数据

如何获得确认按钮值模态

发布于2021-11-03 02:23     阅读(750)     评论(0)     点赞(23)     收藏(3)


假设有一个 html 页面,当我点击一个按钮时,我读到:”

在此处输入图片说明

单击“确定”按钮时需要处理

那是html代码:

     <div class="modal-content">
<div class="modal-body">
<button type="button" class="bootbox-close-button close" data-dismiss="modal" aria-hidden="true" style="margin-top: -10px;">×</button>
<div class="bootbox-body">Are you sure you wish to discard this post?</div></div><div class="modal-footer"><button data-bb-handler="cancel" type="button" class="btn btn-default">Cancel</button><button data-bb-handler="confirm" type="button" class="btn btn-primary">OK</button></div></div>

那是我的 jquery 代码:

(function() {

        $(document).on('click','button[data-bb-handler="confirm"][type="button"]',function(){
            console.log("MAREEEEEEEEEEEEEEEEE "+$(this).length);
        });

}());

它不起作用。任何人都可以帮助我吗?还有什么方法?


解决方案


您可以像这样直接处理事件:

<button id="confirmBtn" type="button" class="btn btn-primary">OK</button>

(function() {

   $("#confirmBtn").click(function(e){
       e.preventDefault();
       console.log("This " + $(this).length);
   })

}());



所属网站分类: 技术文章 > 问答

作者:黑洞官方问答小能手

链接:http://www.qianduanheidong.com/blog/article/216224/bc40c3e419c3193b676b/

来源:前端黑洞网

任何形式的转载都请注明出处,如有侵权 一经发现 必将追究其法律责任

23 0
收藏该文
已收藏

评论内容:(最多支持255个字符)