I'm encountering a problem while trying to switch and add classes to elements when a mouse click event occurs. Likewise I have multiple "li" elements. I want to add "class = subdrop active" to the selected anchor tag and the "class = active" to the subsequent li tag. I'm not sure if I'm handling the class manipulation correctly. Could someone please suggest the right approach?
<li class="submenu">
<a href="javascript:void(0);">
<i class="ti ti-layout-dashboard"></i>
<span>Admin Profile</span>
<span class="menu-arrow"></span>
</a>
<ul>
<li>
<a href="<?php echo base_url('admin_dashboard'); ?>">Dashboard</a>
</li>
<li>
<a href="<?php echo base_url('admin_profile'); ?>">Profile</a>
</li>
<li>
<a href="#">Settings</a>
</li>
<li>
<a href="#">Contacts</a>
</li>
</ul>
</li>
Trying to get the following results on selected li clicks
<li class="submenu">
<a href="javascript:void(0);" class="subdrop active"><i class="ti ti-layout-dashboard"></i><span>Admin Profile</span><span class="menu-arrow"></span>
</a>
<ul>
<li><a href="<?php echo base_url('admin_dashboard'); ?>" class="active">Dashboard</a></li>
<li><a href="<?php echo base_url('admin_profile'); ?>">Profile</a></li>
<li><a href="#">Settings</a></li>
<li><a href="#">Contacts</a></li>
</ul>
</li>