gpt4 book ai didi

javascript - 更改菜单项的事件类别

转载 作者:行者123 更新时间:2023-11-30 15:04:15 24 4
gpt4 key购买 nike

<分区>

我目前正在做一个汽车租赁网站的练习考试。我和我一起工作的 friend 。开始制作管理页面时,我遇到了更改菜单项上的事件类的问题。尝试了很多,但还没有成功。我的问题是如何使用 Javscript 更改菜单项上的事件类?

下面的代码来自管理页面php文件中的nav.php文件

<!-- Navigation -->
<nav class="navbar navbar-expand-lg navbar-dark bg-dark fixed-top" id="mainNav">
<a class="navbar-brand" href="#">Rent an Electric</a>
<button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse"
data-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false"
aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarResponsive">
<ul class="navbar-nav navbar-sidenav" id="exampleAccordion">
<li class="nav-item" data-toggle="tooltip" data-placement="right" title="Dashboard">
<a class="nav-link" href="admin-page-2.php">
<i class="fa fa-fw fa-dashboard"></i>
<span class="nav-link-text">
Dashboard</span>
</a>
</li>
<li class="nav-item" data-toggle="tooltip" data-placement="right" title="Wagenpark">
<a class="nav-link" onclick="return loadQueryResult('wagenpark')" href="page_admin.php?wagenpark">
<i class="fa fa-fw fa-car"></i>
<span class="nav-link-text">
Wagenpark</span>
</a>
</li>
<li class="nav-item" data-toggle="tooltip" data-placement="right" title="Gebruikers">
<a class="nav-link" onclick="return loadQueryResult('gebruikers')" href="page_admin.php?gebruikers">
<i class="fa fa-fw fa-user"></i>
<span class="nav-link-text">
Gebruikers</span>
</a>
</li>
<li class="nav-item" data-toggle="tooltip" data-placement="right" title="Klanten">
<a class="nav-link" onclick="return loadQueryResult('klanten')" href="page_admin.php?klanten">
<i class="fa fa-fw fa-child"></i>
<span class="nav-link-text">
Klanten</span>
</a>
</li>
<li class="nav-item" data-toggle="tooltip" data-placement="right" title="Facturen">
<a class="nav-link" onclick="return loadQueryResult('facturen')" href="page_admin.php?facturen">
<i class="fa fa-fw fa-file"></i>
<span class="nav-link-text">
Facturen</span>
</a>
</li>
<
</ul>
<ul class="navbar-nav sidenav-toggler">
<li class="nav-item">
<a class="nav-link text-center" id="sidenavToggler">
<i class="fa fa-fw fa-angle-left"></i>
</a>
</li>
</ul>
<ul class="navbar-nav ml-auto">

<li class="nav-item">
<a class="nav-link" data-toggle="modal" data-target="#exampleModal">
<i class="fa fa-fw fa-sign-out"></i>
Uitloggen</a>
</li>
</ul>
</div>
</nav>

<script>
function loadQueryResult(name) {
$('.container-fluid').load('includes/admin-page/pages/'+ name +'.php');
return false;
}

//Hier moet nog een function komen voor het aanpassen van de li class naar active
$('.navbar > ul.nav li a').click(function(e) {
var $this = $(this);
$this.parent().siblings().removeClass('active').end().addClass('active');
e.preventDefault();
});
</script>

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com