当我运行以下代码时,我只希望#overlay、#image + theNumber 和#close 处于活动状态,因此我禁用了 $('.box').click 但是一旦单击#close,我想重新启用单击 $('.box') 但到目前为止我无法做到。我已经检查了其他答案,但无法将其放在一起。谢谢您的帮助!!
var handler = function() { var theIDval = $(this).attr('id'); var theNumber = theIDval.replace('box',''); $('.box').unbind('点击'); $('#overlay').show(); $('#image' + theNumber).fadeIn(); $('#close').fadeIn(); $('#close').click( 函数 () { $('#overlay').fadeOut(); $('#image' + theNumber).fadeOut(); $('#close').fadeOut(); }); }; $(文档).ready(函数(){ $('.box').click(handler); });