我遇到了禁用和重新启用链接上的点击事件的问题。条件禁用/重新启用jQuery点击事件
该设置是连续4列,每列包含一个链接和隐藏的内容框。当您单击链接时,它将展开该行并显示特定于该列的内容框。一旦链接被点击并且该行被展开,所有其他链接都将淡出。然后,您将重新点击打开的链接关闭该行并取消淡入其他链接。
我设置这种情况下的工作小提琴,这应有助于解释它...
$('.open-box').click(function(event) {
event.preventDefault();
var $list_row = $(this).parents('.row'),
$column_box = $(this).parent('.column').find('.box');
if ($(this).is('.open')) {
$(this).removeClass('open');
$list_row.stop().animate({ 'padding-bottom': 0 }, 100).removeClass('expanded');
// hide the content box
$column_box.hide();
// find all links and fade them in
$('.box-list').find('.box-link').fadeTo(100, 1).addClass('open-box');
} else {
$(this).addClass('open');
$list_row.stop().animate({ 'padding-bottom': 200 }, 100, function() {
// show the content box
$column_box.fadeIn(100);
}).addClass('expanded');
// find all links and fade them out
$('.box-list').find('.box-link').not(this).fadeTo(100, 0.25).removeClass('open-box');
}
});
我试图做的是所有的褪禁用click事件将链接作为唯一可点击的链接。正如你所看到的,点击淡出链接的行为会让整个事情变得糟糕。
我已经尝试在打开操作(其他)上设置.off('click')
,它可以禁用点击其他链接。并采取关闭行动.on('click')
。关闭操作运行后,其他链接仍不可点击。
任何帮助解决这个问题将非常感激!
你可以只检查不透明度:'如果($(本)的.css( '不透明')<1)回报;'http://jsfiddle.net/r8K78/4/ –
和辉煌很简单!想把它作为答案,以便我可以接受? –