I have written this code in HTML/CSS and jQuery:
$('.myFilters li').click(function() { $(".category").hide(); var v = $(this).text()[0]; $('.title li').hide().filter(function() { return $(this).text().toUpperCase()[0] == v; $(".category:first").show(); }).show().first().find('a[data-toggle]:first').trigger('click'); }) $("a[data-toggle]").on("click", function(e) { e.preventDefault(); // prevent navigating var selector = $(this).data("toggle"); // get corresponding element $(".category").hide(); $(selector).show(); }); $('.myFilters li:first').trigger('click');The CSS snippet:
.myFilters, .title { margin: 0; padding: 0; } /* more CSS styles here */The JavaScript provided:
- A
- B
- C