Abin Jacob Abin Jacob - 3 months ago 7
HTML Question

codeigniter, how to call active class to navigation in single page website?

I am working on a single page website, I have following navigation bars:

<ul class="nav navbar-nav navbar-right">
<li><i></i><a href="#home" class="active">HOME</a></li>
<li><i></i><a href="#accommadation" class="">Accommodation</a></li>
<li><i></i><a href="#activities" class="">activities</a></li>
<li><i></i><a href="#gallery" class="">>gallery</a></li>
<li><i></i><a href="#contact" class="">>contact</a></li>
</ul>


its working on the section id in the section tag. like

<section id="home">
<section id="accommadation">


how to give
class="active"
for navigation?

Answer

Try this

<ul class="nav navbar-nav navbar-right">
    <li><i></i><a href="#home"  class="nav_menu active">HOME</a></li>
    <li><i></i><a href="#accommadation" class="nav_menu ">Accommodation</a></li>
    <li><i></i><a href="#activities" class="nav_menu ">activities</a></li>
    <li><i></i><a href="#gallery" class="nav_menu ">>gallery</a></li>
    <li><i></i><a href="#contact" class="nav_menu ">>contact</a></li>   
</ul>
<script type="text/javascript">
    $(document).ready(function(){
        $('.nav_menu').click(function(){
            $('.nav_menu.active').removeClass('active');
            $(this).addClass('active');
        });
    });
</script>
Comments