Javascript jQuery-激活一个切换按钮将禁用另一个
我有两个jQuery切换按钮的问题。它们用于移动导航按钮:Javascript jQuery-激活一个切换按钮将禁用另一个,javascript,jquery,button,mobile,Javascript,Jquery,Button,Mobile,我有两个jQuery切换按钮的问题。它们用于移动导航按钮: (function($) { $(function() { $('#mobile-nav-button').toggle( function() { $('#fullpage').animate({ left: 250 }, 'normal', function() { $('#mobile-nav-button').html('Close');{ $('#
(function($) {
$(function() {
$('#mobile-nav-button').toggle(
function() {
$('#fullpage').animate({ left: 250 }, 'normal', function() {
$('#mobile-nav-button').html('Close');{
$('#social-nav-panel').hide();
}
});
},
function() {
$('#fullpage').animate({ left: 0 }, 'normal', function() {
$('#mobile-nav-button').html('Open');
});
}
);
$('#social-nav-button').toggle(
function() {
$('#fullpage').animate({ right: 250 }, 'normal', function() {
$('#social-nav-button').html('Close');
});
},
function() {
$('#fullpage').animate({ right: 0 }, 'normal', function() {
$('#social-nav-button').html('Open');
});
}
);
});
})(jQuery);
他们自己干得很好。第一个按钮#移动导航按钮每次都能完美工作。第二个按钮#社交导航按钮也可以正常工作。但是,如果选择了#移动导航按钮,则#社交导航按钮将停止工作(这不会反过来应用,因为#移动导航按钮将始终工作,即使选择了#社交导航按钮)
我看过很多关于堆栈溢出的类似文章(虽然不是同一个问题),但遗憾的是,我的JS/jQuery知识远远不够好,无法对我的问题进行任何修复
任何帮助都将不胜感激 您可以查看我的示例: HTML:
这是因为您使用的方法已被弃用并删除,截至目前,toggle()仅隐藏和显示元素。我知道这个方法从1.9版开始就被删除了,但我看到的所有其他移动导航解决方案都让我头晕目眩,这真是个奇迹。使我的一个按钮完全消失(因此我无法再次单击它以使其恢复原始状态)。这是我工作的原始代码,-但是有两个按钮(一个在左边,如图所示)和另一个在右边做相同的操作,但是如果这有意义的话,方向相反?
<button type="button" id="mobile_bt">Mobile</button>
<button type="button" id="social_bt">Social</button>
$('#mobile_bt').click(function() {
var help= $(this);
$('#social_bt').toggle('slow', function() {
help.hide();
$(this).show();
});
});
$('#social_bt').click(function() {
var help= $(this);
$('#mobile_bt').toggle('slow', function() {
help.hide();
$(this).show();
});
});