vendredi 29 janvier 2016

If statement works in console, not in source

I have the following if statement within a click function:

$('#rent-link').on('click', function() {
  $('.house-card:not(.sold)').fadeIn('fast');
  $('.for-sale').fadeOut('fast');
  $('.rental').fadeIn('fast');
  $('.sold').fadeOut('fast');
  $('.comm').fadeOut('fast');
  if ( $('.house-card:visible').length == 0 ) {
    $('#no-results').show();
  }
  return false;
});

All of the code is wrapped in a doc ready function so that can't be the problem. I am not sure why that when the parameters are set for this if statement to resolve true, it always resolves false. When I click #rent-link and then run the if statement alone in console it resolves true.

Thanks for the help.

Aucun commentaire:

Enregistrer un commentaire