title: How to add active class to codeigniter hyperlinks?
body: <p>I know this question comes across a lot, but I just can't figure out how to do this using the, already answered posts.</p>
  
  <p>I have a header with navigation links. I would like to add <code>class="active"</code> to the link that's active at the moment.</p>
  
  <p>How could I do this if I have the following navigation?</p>
  
  <pre><code>&lt;nav&gt;
      &lt;ul id="main_nav"&gt;
          &lt;li class="home"&gt;
              &lt;a href="search"&gt;
                  &lt;i class="icon-search"&gt;&lt;/i&gt;
                  &lt;span&gt;BEDRIJF ZOEKEN&lt;/span&gt;
              &lt;/a&gt;
          &lt;/li&gt;
          &lt;li class="categorie"&gt;
              &lt;a href="categorieen/all"&gt;
                  &lt;i class="icon-list-ul"&gt;&lt;/i&gt;
                      &lt;span&gt;CATEGORIE&lt;/span&gt;
              &lt;/a&gt;
          &lt;/li&gt;
          &lt;li class="aanbieding"&gt;
              &lt;a href="aanbiedingen"&gt;
                  &lt;i class="icon-shopping-cart"&gt;&lt;/i&gt;
                      &lt;span&gt;AANBIEDING&lt;/span&gt;
              &lt;/a&gt;
          &lt;/li&gt;
          &lt;li class="vacature"&gt;
              &lt;a href="vacatures"&gt;
                  &lt;i class="icon-copy"&gt;&lt;/i&gt;
                  &lt;span&gt;VACATURE&lt;/span&gt;
              &lt;/a&gt;
          &lt;/li&gt;
          &lt;li class="agenda"&gt;
              &lt;a href="agenda"&gt;
                  &lt;i class="icon-calendar"&gt;&lt;/i&gt;
                  &lt;span&gt;AGENDA&lt;/span&gt;
              &lt;/a&gt;
          &lt;/li&gt;
          &lt;li class="contact"&gt;
              &lt;a href="contact"&gt;
                  &lt;i class="icon-envelope"&gt;&lt;/i&gt;
                  &lt;span&gt;CONTACT&lt;/span&gt;
              &lt;/a&gt;
          &lt;/li&gt;
      &lt;/ul&gt;
  &lt;/nav&gt;
  </code></pre>
  
  <p>I tried this, but it did not work:</p>
  
  <pre><code>&lt;script&gt;
  $(function() {
      var href = $(this).find('a').attr('href');
      alert(window.location.pathname)
      if (href === window.location.pathname) {
        $(this).addClass('active');
      }
  }); 
  &lt;/script&gt;   
  </code></pre>
  
  <p>Maybe there's a better Codeigniter-ish way?</p>