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");
Change the line
if($(listType) == true){
to
if($(listType).length > 0){
精彩评论