jQuery代码
$(document).ready(function(){
$(".searchkeyword").keyup(function(){
var str = $(".searchkeyword").val();
var count = 0;
//loop through the friendslist
$(".friendslist .holder").each(function(index){
if($(this).attr("id")){
//case insenstive search
if(!$(this).attr("id").match(new RegExp(str, "i"))){
$(this).fadeOut("fast");
}else{
$(this).fadeIn("slow");
count++;
}
}
});
//display no of results box when str is not empty
if(str == '') { $("#result_area").hide(); } else { $("#result_area").show(); }
//display no of results found
$("#result_area").text("Top "+count+" results for "+str);
});
});