Here’s my code:
function mouseOver(variable)
{
return function()
{
$(variable).fadeIn(100);
};
}
function mouseOut(variable)
{
return function()
{
$(variable).fadeOut(100);
};
}
function lawyer(var1, var2, var3, var4)
{
return function()
{
$(var1).bind('mouseenter', mouseOver(var2)).bind('mouseleave', mouseOut(var2)).click(
function()
{
$(var1).unbind('mouseenter').unbind('mouseleave');
$(var1).removeClass('off').addClass('on');
$(var3).bind('mouseenter', mouseOver(var4)).bind('mouseleave', mouseOut(var4));
$(var3).removeClass('on').addClass('off');
$(var4).hide();
});
}
}
lawyer("#group", ".b", "#group2", ".l");
What would be the reason for this not working?
It works in that it hides $(var4).hide();, but clicking on the object doesn’t seem to do anything. It works if I take the code out of a function and just copy/paste it a few times and change the targets.
I’m not seeing it… Any help would be appreciated!
It’s unclear to me why you’re returning a new function from
lawyer(). Your call tolawyer(...)does not execute the returned function. Could that be the reason?One technique I use often to determine whether some particular bit of code is even being run at all, is to insert an
alert("hi")or something in there. If you don’t see the alert, the code isn’t being run.