您好,我正在尝试使我的导航栏在 php 中处于事件状态,以便用户可以知道他们在哪个页面上。那么我如何在这段代码中添加一个 class="active"来创建一个事件的导航栏并在同一个 index.php 页面中显示所有页面。
<?php
return "<nav id='nav-reservation'>
<a href='resource-index.php?page=room' class='nav-reservation-item'>Room</a> |
<a href='resource-index.php?page=equipment' class='nav-reservation-item'>Equipment</a>
</nav>
";
最佳答案
您可以为相同的 [ http://jsfiddle.net/Ag47D/3/ 使用手动 css ]
或
您可以使用 Bootstrap [ http://www.bootply.com/IsRfOyf0f9 ]
$(".nav b").on("click", function(){
$(".nav").find(".active").removeClass("active");
$(this).parent().addClass("active");
});
关于php - 如何在PHP中的导航栏中添加动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41756214/