所以我有这个侧边栏,我想切换它的行为。 而不是像这样关闭:
我想在网站启动时保持其打开状态,如下所示:
这是 JavaScript
<script type="text/javascript">
$(function() {
$('.navbar-toggler').on('click', function(event) {
event.preventDefault();
$(this).closest('.navbar-minimal').toggleClass('open');
})
});
</script>
和 HTML
<nav class="navbar navbar-fixed-left navbar-minimal animate" role="navigation" id="sidebar-1">
<div class="navbar-toggler animate">
<span class="menu-icon"></span>
<p id="menutab">Menu</p>
</div>
<ul class="navbar-menu animate">
<li class="dropdown" id="dropdown-nav">
<a href="#" class="animate dropdown-toggle" data-toggle="dropdown">
<span class="desc animate" style="font-family: 'Roboto Condensed', sans-serif;">Top 5 Events</span>
<span class="mini-icon"><img src="Images/ps/Events.png" id="mini-icon"></span>
</a>
<ul class="dropdown-menu" id="events">
<iframe src="Php/events.php" id="iframe" frameborder="0" marginheight="0" marginwidth="0" width="100%" height="100%" scrolling="auto">
<p>Your browser does not support iframes.</p>
</iframe>
</ul>
</li>
最佳答案
<nav class="navbar navbar-fixed-left navbar-minimal animate"
转到 html 标记中的上述行并添加类“open”,如下所示
<nav class="navbar navbar-fixed-left navbar-minimal animate open"
所以它会默认打开。
关于Javascript - 侧边栏切换始终打开,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36112307/