1
var $div = "<div id=\"success\" class=\"modal hide fade\" tabindex=\"-1\" data-backdrop=\"true\" role=\"dialog\"><div class=\"modal-header btn-primary\"><button type=\"button\" class=\"close\" data-dismiss=\"modal\">×</button><h3>Success</h3></div><div class=\"modal-body\"><p>Update Success, continue?</p></div><div class=\"modal-footer\"><button class=\"btn\" data-dismiss=\"modal\">Yes</button><button class=\"btn\" id=\"no\" data-dismiss=\"modal\">No</button></div></div>";
                $($div).appendTo('body').modal("show");

$('#no').on('Click', function(){

});

在任何地方单击#no 选择器?

4

1 回答 1

1

您需要使用委托事件:

$(document).on('click', '#no', function() {
    ...
});

检查文档

于 2013-08-05T10:19:09.453 回答