Joshua Robison
Joshua Robison

Reputation: 1881

problem passing variables into javascript function

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");

Upvotes: 1

Views: 297

Answers (1)

Chandu
Chandu

Reputation: 82903

Change the line

if($(listType) == true){

to

if($(listType).length > 0){

Upvotes: 2

Related Questions