[英]How to hide navbar-toggle in jQuery when the search button is clicked?
I have a small problem with my website. 我的网站有一个小问题。 In the header there are 2 buttons with 2 different codes ( 1 for open/close the menu and 1 for open/close the search ).
标题中有2个按钮,带有2个不同的代码(1个用于打开/关闭菜单,1个用于打开/关闭搜索)。
This code works nice, it open and close the menu. 这段代码很好用,它可以打开和关闭菜单。
! function(a) {
a(".navbar-toggle").on("click", function() {
a(this).toggleClass("open"), a("#navigation").slideToggle(400)
}), a(".navigation-menu>li").slice(-1).addClass("last-elements"), a(".crspnt").on("click", function(b) {
a(window).width() < 992 && (b.preventDefault(), a(this).parent("li").toggleClass("open").find(".submenu:first").toggleClass("open"))
})
}
Also this code works nice, it open the search box: 这段代码也很好用,它打开了搜索框:
(jQuery), $("search-btn").on("click", function() {
$("#show-search-box").css("display", "block")
});
The problem is that when the menu is open and I open the search, it looks very bad. 问题是,当菜单打开并且我打开搜索时,它看起来非常糟糕。
I need to change the 2nd code ( of the search ) and add the function that when the search button is clicked the menu close. 我需要更改(搜索的)第二个代码,并添加单击搜索按钮时菜单关闭的功能。
Any Idea? 任何想法?
Thank you 谢谢
Remove the class from the menu: 从菜单中删除该类:
(jQuery), $("search-btn").on("click", function() {
jQuery(".navbar-toggle").removeClass('open');
$("#show-search-box").css("display", "block")
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.