The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Count filtered list items Reply To: Count filtered list items


I finally got everything working…and then some! Thankfully, jquery is “easy” to read, so I’ll let the code speak for itself (what the functions are).

var $nopestprofessional = $('#nopestprofessional')
var n = $('').length;
if (n < 1) {$nopestprofessional.removeClass('tab').addClass('tab1');
$('#nopestprofessional p').css('marginBottom', '20px');
$('div.servicearea li').css("list-style", "none").css("line-height", "17px");}
else {
jQuery.fn.shuffle = (function(){ 
function ListShuffle(arr) { 
var i = arr.length, r, tempI, tempR; 
if ( i === 0 ) {return arr;} 
while ( i-- ) { 
r = Math.floor(Math.random() * (i + 1));
tempI = arr[i];
tempR = arr[r];
arr[i] = tempR;
arr[r] = tempI;} 
return arr;}
return function(s) {return this.each(function(){var container = jQuery(this); 
.bind('click',function(e) {
.bind('click',function(e) {
.bind('click',function(e) {
$('.coverm h2').animate({"color": "#ff7700", "textShadow": "2px 2px 3px #111111"},{duration: 2400})
.animate({"color": "#ffffff", "textShadow": "0px 0px 10px #ffffff"},{queue: true, duration: 1000})
.animate({"color": "#ff7700", "textShadow": "2px 2px 3px #111111"},{queue: true, duration: 1500});})
.bind('click',function(e) {
.bind('click',function(e) {
$('.flipbutton a').click(function(e){
$('div.servicearea li').css("list-style", "none").css("line-height", "17px");
$('#filter a').click(function(e){
$('#filter a').removeClass('active');
var filter = $(this).attr('id');
var $filteredItems = $("." + filter);
if ($filteredItems.length == 0) {$(this).addClass('active');
$('#nopestprofessional h2').replaceWith('<h2>There are currently no listings for this service in your area.</h2>');
$('#nopestprofessional p').replaceWith('

Find pest professionals from a neighboring city/county who may offer this service in your area.

'); $('#nopestprofessional p').css('marginBottom', '20px'); } else { $(this).addClass('active'); $('#list li').show(); $('#list li:not(.' + filter + ')').hide(); $nopestprofessional.removeClass('tab1').addClass('tab');} }); });

The live site:—Midlothian%2C-VA—Chester%2C-VA—Moseley%2C-VA.php

Now I’ve gotta debug for IE.