假设有一个 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);
})
}());
关于javascript - 如何获取确认按钮值模式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39588565/