var dialog = function(title,content,callback){ var html = '<div class="modal fade" id="dialog_Modal_1" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" display="hidden">'; html += '<div class="modal-dialog">'; html += '<div class="modal-content">'; html += '<div class="modal-header">'; html += '<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>'; html += '<h4 class="modal-title" id="myModalLabel">'+title+'</h4>'; html += '</div>'; html += '<div class="modal-body">'+content+'</div>'; html += '<div class="modal-footer">'; html += '<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>'; html += '<button type="button" class="btn btn-primary" data-dismiss="modal">确定</button>'; html += '</div>'; html += '</div>'; html += '</div>'; html += '</div>'; if (!$('#myModal').length) { $('body').append(html); $('#myModal').modal('show'); } $('#dialog_Modal_1 .btn-primary').click(function(event) { callback(); }); $('#dialog_Modal_1').modal('show'); };
转载于:https://www.cnblogs.com/xiaozhu520/p/9937046.html