1

For some reason when I hover over these objects, no matter what I get the FALSE alert. why?

function hoverEffect(listType, button, animatedObject){

    var button = $(button), animatedObject = $(animatedObject), listType = $(listType);

  if($(listType) == true){

    $(button).hover(function(){
    alert("listType = true");
      $(this).stop(true, true);
      $(this).toggleClass("mouseIn", 1000, 'easeOutQuint');
    }, function(){
      $(this).stop(true, true);
      $(this).removeClass("mouseIn",  1000, 'easeOutQuint');
    });

  }else{

    $(button).hover(function(){  
    alert("listType = false");
      $(animatedObject).stop(true, true);
      $(animatedObject).toggleClass("mouseIn", 1000, 'easeOutQuint');
    }, function(){
      $(animatedObject).stop(true, true);
      $(animatedObject).removeClass("mouseIn",  1000, 'easeOutQuint');
    });

  }


}



hoverEffect(false, "#globalNavButton", "#globalNavButton");
hoverEffect(false, "#reelButton", "#reelButton");
hoverEffect(true, ".listHover");

1 Answer 1

2

Change the line

if($(listType) == true){

to

if($(listType).length > 0){
Sign up to request clarification or add additional context in comments.

2 Comments

thanks that worked but ... wish I knew why. I see what you are doing but it should work to say if (listType == true) why doesnt that work?
$(null) evaluates a object and when you equate it to true the expression never evaluates to true.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.