jQuery - 激活一个切换按钮会禁用另一个
jQuery - Activating one toggle button disables the other
我在使用两个jQuery切换按钮时遇到问题。它们用于移动导航按钮:
(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);
他们自己工作正常。第一个按钮 #mobile 导航按钮每次都能完美运行。第二个按钮 #social 导航按钮也可以正常工作。但是,如果选择了 #mobile-nav-button,则 #social-nav-button将停止工作(这不适用于相反的方式,因为 #mobule-nav-button将始终有效,即使选择了 #social-nav-button)。
我已经看到了很多关于堆栈溢出的类似帖子(虽然不是同一个问题),但遗憾的是,我的 JS/jQuery 知识远远不足以对我的问题应用任何修复。
任何帮助将不胜感激!
你可以检查我的例子: 切换按钮显示和隐藏
.HTML:
<button type="button" id="mobile_bt">Mobile</button>
<button type="button" id="social_bt">Social</button>
使用 jQuery 的 JS:
$('#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();
});
});
相关文章:
- 单击转盘按钮后重定向到另一个页面
- 如何在单击按钮时显示一个分区,同时隐藏另一个分区
- jquery点击另一个网站上的按钮
- 如何使用Twitter引导程序点击按钮导航到另一个页面
- 将按钮链接到另一个页面的一部分
- Jquery:如果选中了另一个按钮,则为未选中按钮
- 如何将图像制作为按钮并将其重定向到另一个页面
- 单击输入时,将提交按钮设置为另一个
- 将按钮名称和值传递给另一个 JavaScript 页面
- 在单击按钮时激活按钮的悬停状态,直到单击另一个按钮(Javascript/JQuery)
- TinyMCE 将另一个事件添加到粗体和斜体按钮
- 禁用另一个元素内的元素,除非它是按钮
- 将搜索按钮从一个站点复制到另一个站点:此搜索按钮如何工作,以及如何重现其操作
- 具有双重功能的按钮:在_blank窗口中打开一个链接,再加上_self中的另一个链接
- 使用单选按钮参考另一个功能
- 单击单选按钮禁用另一个单选按钮
- 如何使Angular打开一个按钮并关闭另一个按钮
- 另一个按钮内的按钮不会;不能在Firefox(Angular Material)中工作
- 按钮onclick应该与参数一起重定向到另一个xhtml页面
- 如何通过单击另一个按钮使按钮可见