[英]Change the menu sidebar based on the menu item selected - Semantic UI & JQuery
I'd like to use SemanticUI to display different sidebars based on selected menu 我想使用SemanticUI根据所选菜单显示不同的侧边栏
I've tried one way, but it doesn't seem to work. 我尝试了一种方法,但它似乎没有用。 Codepen link
Codepen链接
Here, i have 2 menu items for the sidebar, i need to show ' first_sidebar
' if i'm inside the menu ' First
', if i'm inside ' Second
', i need to show the ' second-sidebar
'. 在这里,我有侧边栏的2个菜单项,我需要显示'
first_sidebar
',如果我在菜单' First
',如果我在' Second
',我需要显示' second-sidebar
'。
Thanks! 谢谢!
You are trying to show and hide sidebar as an ordinary HTML element with jQuery, using $("div.second_sidebar").hide()
and $("div.first_sidebar").show()
. 您正尝试使用
$("div.second_sidebar").hide()
和$("div.first_sidebar").show()
来显示和隐藏侧边栏作为jQuery的普通HTML元素。
But, since sidebars are Semantic UI element that you initialized with .sidebar()
method, you should use this same method to show and hide sidebars, eg: 但是,由于侧边栏是使用
.sidebar()
方法初始化的语义UI元素,因此您应该使用相同的方法来显示和隐藏侧边栏,例如:
$("div.second_sidebar").sidebar('hide');
$("div.first_sidebar").sidebar('show');
Reference is here: https://semantic-ui.com/modules/sidebar.html#/usage 参考文献: https : //semantic-ui.com/modules/sidebar.html#/usage
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.