How to toggle a highlighted selected item in a group list

Here we go buddy. I have made a JSfiddle for ya

demo

$(function(){
    console.log('ready');

    $('.list-group li').click(function(e) {
        e.preventDefault()

        $that = $(this);

        $that.parent().find('li').removeClass('active');
        $that.addClass('active');
    });
})

JSFiddle updated to have more than one Group

http://jsfiddle.net/mgjk3xk2/1/


If you'd be using jQuery, it looks like this:

$(".list-group .list-group-item").click(function(e) {
   $(".list-group .list-group-item").removeClass("active");
   $(e.target).addClass("active");
});