Another jQuery filter by click event
Usage: Here my requirement is i need to search users by using their category(ex: music director and singer) on click
As of now i don't have demo space..
Simply take a copy of this code and paste in a notepad then save as html open in browser and check
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Simple and Small Jquery Filter</title>
<script src="http://code.jquery.com/jquery-1.10.2.js"></script>
</head>
<body>
<ul style="float:left">
<li>
<div class="name">Devi sri prasad</div>
<div class="ltype">Music director</div>
</li>
<li>
<div class="name">Mani Sharma</div>
<div class="ltype">Music director</div>
</li>
<li>
<div class="name">anoop rubens</div>
<div class="ltype">Music director</div>
</li>
<li>
<div class="name">yesu dasu</div>
<div class="ltype">singer</div>
</li>
<li>
<div class="name">S.P.Balu</div>
<div class="ltype">singer</div>
</li>
<li>
<div class="name">shankar mahadevan</div>
<div class="ltype">singer</div>
</li>
<li>
<div class="name">Shreya Ghoshal</div>
<div class="ltype">singer</div>
</li>
<br>
</ul>
<div style="float:left"><a href="javascript:void(0);">singer</a> <br> <a href="javascript:void(0);">Music director</a> </div>
<script>
$(document).on('click','a',function(){
var searchval = $(this).text();
$("ul li .ltype:contains("+searchval+")").parent('li').css("display","block");
$("ul li .ltype:not(:contains("+searchval+"))").parent('li').css("display","none");
});
</script>
</body>
</html>