In the following very simple Script. Why, after switching to Active and coloring it of the desired color, once the view has been loaded, is the asset reset to the active item by Default? what will be happening.
HTML
<div class="list-group">
<a class="list-group-item active" href="@Url.Action("Index", "Sistema")"><i class="fa fa-home fa-fw" aria-hidden="true"></i> Inicio</a>
<a class="list-group-item" href="@Url.Action("Users", "Sistema")"><i class="fa fa-user-o fa-fw" aria-hidden="true"></i> Usuarios</a>
<a class="list-group-item" href="@Url.Action("Ajustes", "Sistema")"><i class="fa fa-cog fa-fw" aria-hidden="true"></i> Ajustes</a>
</div>
JS
$(function () {
//Elementos de la Lista
var Items = $(".list-group a");
// manejador de click sobre todos los elementos
Items.click(function () {
// eliminamos active de todos los elementos
Items.removeClass('active');
// activamos el elemento clicado.
$(this).addClass('active');
});
});
CSS
.active {
background: #337AB7;
}