I am trying to make a simple content-sliding thingy and got stuck writing the code for probably the simplest stuff - handling hover for the navigation part of the slider. I want it to be so that when one of the divs with slide info has been clicked on, the hover doesn't work for it, but works for the other two divs.
I've tried classes and id's for the clicked div, but nothing works when I'm getting to the hover part. I'm trying to use :not filter to select the other two divs, or all three, the ones that have not been #clicked. But there isn't much selection going on - no matter what, hover works for all three divs. I've tried using :not with other functions, like hide(), and it works just fine. So is this a CSS specificity issue? Or is it something wrong with mouseover/mouseout? Or maybe with me, like being an incompetent fool?
Here's my html:
<div id="linkswrapper">
<div>
<a>Slide 1</a>
<p>Slide info 1.</p>
</div>
<div>
<a>Slide 2</a><p>Slide info 2.</p>
</div>
<div>
<a>Slide 3</a>
<p>Slide 3 info.</p>
</div>
</div>
Here's the jquery code:
// adds href="#" to all links in "linkswrapper" div
$("#linkswrapper div a").attr({href: "#"});
// this handles clicks on the divs. When clicked, the div is assigned
// "clicked" id, and the id attribute is removed from the other sibling divs
$("#linkswrapper div").click(function() {
$(this).attr({id:"clicked"});
$("#linkswrapper div").not(this).each(function(){ $(this).removeAttr("id"); });
});
// handling the mouseover/mouseout. Hover should be working on all the three divs
// if neither of them has been clicked on or only on the two other divs if one
// of the three has been clicked on
$("#linkswrapper div:not(#clicked)").mouseover(function() {
$("a", this).css("border-color","#0066FF");
$("p", this).css("color","#0066FF");
}).mouseout(function(){
$("a", this).css("border-color","#e3e3e3");
$("p", this).css("color","#cccccc");
});