活动导航菜单不起作用。? [英] Active navigation menu not working.?

查看:64
本文介绍了活动导航菜单不起作用。?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我使用ul li元素创建了菜单但点击了哪个菜单项点击该项目应为红色。

它的工作没有'a'标签。但是页面上的标签重定向它的颜色没有显示。



如何用标签做这个?请帮帮我。



我尝试了什么:



Hi,

I created menu using ul li element but on click which menu item clicked that item should be in red color.
its working without 'a' tag. but with a tag on page redirect its color is not showing .

how to do this with a tag? Please help me.

What I have tried:

<ul class="nav">
     <li class="LogoStyle">
         <a href=@Url.Action("Index", "Home")>
            <p>Analog Dashboard</p>
         </a>
     </li>
	<li>
         <a href=@Url.Action("Index", "Home")>
            <p>Digital Dashboard</p>
         </a>
     </li>
     <li>
         <a href=@Url.Action("Index", "Home")>
            <p>Report</p>
         </a>
     </li>
     <li>
         <a href=@Url.Action("Index", "Home")>
            <p>Signal</p>
         </a>
     </li>
</ul>




$(document).ready(function () {
        var selector = '.nav li';
        $(selector).on('click', function () {
            $(selector).removeClass('LogoStyle');
            $(this).addClass('LogoStyle');
        });
    });




.LogoStyle {
    color: red;
    font-weight: 500;
}

推荐答案

document )。ready(< span class =code-keyword> function (){
var selector = ' .nav li';
(document).ready(function () { var selector = '.nav li';


(selector).on(' 点击'功能(){
(selector).on('click', function () {


(selector).removeClass(' LogoStyle');
(selector).removeClass('LogoStyle');


这篇关于活动导航菜单不起作用。?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆