I am completely new to javascript and jQuery, so this question may seem dumb, but I could not find any example or document on it.
I got this function for a little flipping and deploying color animation that works great:
$(".box_nav").hover(function(){ jQuery(this).stop(true, false); $(this).animate({ backgroundColor: "#fff"}, 300 ); }, function() { jQuery(this).stop(true, false); $(this).animate({ backgroundColor: "#000"}, 300 ); } );
The fact that I added an added button to change the stylesheet, which also works fine:
$(".black-white").click(function(){ $("link").attr("href", "<?php bloginfo("template_url"); ?>/css/styles-black-white.css"); $(".wp-polls-loading").css({ display:"none"}); return false; }); $(".grey-white").click(function(){ $("link").attr("href", "<?php bloginfo("template_url"); ?>/css/styles-grey-white.css"); $(".wp-polls-loading").css({ display:"none"}); return false; });
The fact is that I would like to create a condition in my inverted menu so that I can switch the color of this too.
So, I tried a few things like this:
///////////////////////////////////////////////////////////////////////////// //Stylesheet change $(".black-white").click(function(){ $("link").attr("href", "<?php bloginfo("template_url"); ?>/css/styles-black-white.css"); $(".wp-polls-loading").css({ display:"none"}); var tt = "black"; return false; }); $(".grey-white").click(function(){ $("link").attr("href", "<?php bloginfo("template_url"); ?>/css/styles-grey-white.css"); $(".wp-polls-loading").css({ display:"none"}); var tt = "grey"; return false; }); ///////////////////////////////////////////////////////////////////////////// //Over menu if (tt == "black"){ $(".box_nav").hover(function(){ jQuery(this).stop(true, false); $(this).animate({ backgroundColor: "#fff"}, 300 ); }, function() { jQuery(this).stop(true, false); $(this).animate({ backgroundColor: "#000"}, 300 ); } ); }else { $(".box_nav").hover(function(){ jQuery(this).stop(true, false); $(this).animate({ backgroundColor: "#000"}, 300 ); }, function() { jQuery(this).stop(true, false); $(this).animate({ backgroundColor: "#e2e2e2"}, 300 ); } ); }
But of course it doesn’t. The only thing that works a bit is if I changed the “black” in if () sor, whatever it does, the second roll-over style.
Any idea?