这是用 jquery 在外部 .js 中编写的...
我有两个窗口可以滑入和滑出 View ,例如:
$(document).ready(function() {
// hides gallery1 as soon as the DOM is ready
$('#gallery1').hide();
// shows the menu on click
$('#showgal1').click(function() {
$('#gallery1').delay(490).show('slide', {direction:'left'});
$('#gallery2').hide('slide', {direction:'right'});
//need code to disable showgal1 and enable showgal2
});
$('#showgal2').click(function() {
$('#gallery2').delay(490).show('slide', {direction:'right'});
$('#gallery1').hide('slide', {direction:'left'});
//need code to disable showgal2 and enable showgal1
});
});
“gallery1”和“gallery2”是带有 Flash 图像画廊的 DIV,“showgal1”和“showgal2”是 anchor 的 ID...
看起来像
<a href="#" id="showgal1">gallery 1</a>
我找不到一种方法来在单击一个功能时禁用 .click 功能并重新启用另一个功能...
我想默认禁用“showgal1”,当“showgal2”事件发生时,它会删除该属性并禁用“showgal2”,直到单击“showgal1”为止...
.attr('disabled','disabled')
尚未工作...
最佳答案
如果关联的图库已经可见,您想在单击 showgal
时停止任何操作吗?
$('#showgal1').click(function(){
if($('#gallery1').is(":visible"))
return false;
$('#gallery1').delay(490).show('slide', {direction:'right'});
$('#gallery2').hide('slide', {direction:'left'});
});
$('#showgal2').click(function(){
if($('#gallery2').is(":visible"))
return false;
$('#gallery2').delay(490).show('slide', {direction:'right'});
$('#gallery1').hide('slide', {direction:'left'});
});
如果相应的图库已经可见,每个click
函数的前两行将停止该函数。
关于jquery - 禁用 jquery 中 anchor 上的 .click 功能,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4531917/