CodeIgniter Forums
HTML helper: adding classes to li using ul() - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: HTML helper: adding classes to li using ul() (/thread-33814.html)



HTML helper: adding classes to li using ul() - El Forum - 09-09-2010

[eluser]stef25[/eluser]
I'm using the HTML helper to print out the main navigation of my site in an unordered list. Is there any way I can add a class="active" to a list item?

If
Code:
$this->uri->segment(2) == "red"
I'd like to add class="active" to the html output for that element.


Code:
$list = array(
            'red',
            'blue',
            'green',
            'yellow'
            );