how to filter un-ordered list using jquery or javascript

on this template 

if you click on sub menu, ALL, Design, Graphic etc the irrelevant div's become invisible. I am creating a similar layout using list li elements. How can we hide a li using javascript or Jquery

Who is Participating?
WebDevEMConnect With a Mentor Commented:
This should do what you need...

<ul id="dynamicUL">
<li class="typeA">One</li>
<li class="typeB">Two</li>
<li class="typeA">Three</li>
<a href="#" id="Link1">Hide Type A</a><br>
<a href="#" id="Link2">Hide Type B</a><br>
<a href="#" id="Link3">Show All</a><br>
<a href="#" id="Link4">Only Show Type B</a>¿

Open in new window

$('#Link1').click(function() {
$('#Link2').click(function() {

$('#Link3').click(function() {
    $('#dynamicUL li').show();
$('#Link4').click(function() {

Open in new window

Julian HansenCommented:
This is the essence of it.
<!doctype html>
<script src=""></script>
<script type="text/javascript">
$(function() {
  $('button.hidebutton').click(function() {
     $('li.' + $(this).attr('id')).hide();
<style type="text/css">
  <li class="firstbutton">First of first</li>
  <li class="firstbutton">Second of first</li>
  <li class="secondbutton">First of second</li>
  <li class="secondbutton">Second of second</li>
<button id="firstbutton" class="hidebutton">First Button</button>
<button id="secondbutton" class="hidebutton">Second Button</button>

Open in new window

(in my post, ignore the weird question marks... copy/paste seems to have grabbed something that wasn't visible on the page)
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.