Click here to Skip to main content
15,885,985 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have used these for highlighted the selected link but after clicking that link the link background color deactivated so please help how to resolve this


this is my code

JS
XML
<script src='http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js'></script>
   <script type="text/javascript">

       $(document).ready(function () {
           $('.header a').click(function () {
               $('.header').removeClass('active');
               $(this).parent().addClass('active');
           });
       });
   </script>


CSS
XML
<style type="text/css">
       .header {

           font-size: 16px;
           width:120px;
       }

       .active {
           background-color: red;
       }
       .active a {
            color:yellow;
        }

   </style>


Asp.net
XML
<div class="header">
       <ul>
           <li class="header">
               <a href="#">Home</a>
           </li>

           <li class="header">
               <a href="#">about</a>
           </li>

           <li class="header">
               <a href="#">contact</a>
           </li>
   </div>
Posted

1 solution

Apply different CssClass for the Div and the Li since elements are selected with Class names.

Try

jquery-menu-active-link[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900