I have 2 divs side by side and by default one is hidden and one is visible.
I have a jQuery function which, when mouseenter the visible div, the hidden one shows. And when mouseenter again, it becomes hidden again. (This is for a login box)
However - I want the always visible div (the mouseenter target) to change color depending on what state the toggled div is in. So far, I can get it to change color upon first mouseenter but it won't change again after that.
Here is the code I have so far:
<script>
$(document).ready(function () {
$(#loginBox).hide();
$(#sideBar).show();
$('#sideBar').mouseenter(function () {
$(#loginBox).toggle(slide);
if ($('#loginBox').is(:visible)) {
$(#sideBar).css(background-color,blue);
} else if ($('#loginBox').is(:hidden)) {
$(#sideBar).css(background-color,yellow);
}
});
});
</script>
So it starts off in its default color (grey by the style sheet) and when mouseenters it loginBox becomes visible and the sideBar turns blue. But when mouseenters again, even though loginBox becomes hidden, the sideBar remains blue.