如何触发模态按钮上的单击事件 window

How to trigger on click event to a button which is on a modal window

我正在开发一个应用程序,需要将模态内容保存到 excel sheet 中。所以我创建了一个按钮 'Export to Excel' 并尝试绑定点击事件。但是我做不到。如果有人能提供帮助,我将不胜感激

http://jsfiddle.net/czACy/1/

我使用了以下代码来触发:

$(document).ready(function(){
    $('div[id^=modal]').on("show", function(){
        $('div[id^=modal] #excelImport').on('click', function(evt){
            //evt.stopPropagation();
           alert('hello'); 
        });
    });
});

像这样? http://jsfiddle.net/kbypftgv/1/

我认为你的 jquery 事件嵌套太具体了

$(document).ready(function(){
    $('div[id^=modal] #excelImport').on('click', function(evt){
        console.log('click');
        alert('hello'); 
    });
});