$(document).ready(function(){
$('#rest').colorbox();
$("#cboxClose").click(function(){ $.fn.colorbox.close(); });
var cboxClose = $.fn.colorbox.close;
$.fn.colorbox.close = function(){ if(confirm("Are you sure?")) { cboxClose(); } }
});
当我确认对话框时,此代码关闭了我的jquery颜色框,但是如果我点击取消(!确认)它关闭
我做错了什么?
答案 0 :(得分:1)
我认为这可以做得更简单
$(function(){
$('#rest').colorbox();
// If close button is clicked...
$("#cboxClose").click(function(){
// Confirm desire to close, and only close if confirmed
if(confirm("Are you sure?")){ $.colorbox.close(); };
});
});
注意:
的 $(function() { ... });
is synonymous with $(document).ready(function() { ... });
强>