我想做一个简单的内容滑动thingy和卡住写代码可能是最简单的东西 - 处理悬停滑块的导航部分。我希望它是这样的,当一个具有幻灯片信息的div被点击时,悬停不起作用,但适用于其他两个div。Mouseover/mouseout +:不是jQuery的问题
我已经尝试过类和id的点击div,但没有任何作品,当我到达悬停部分。我试图使用:不过滤选择其他两个div,或全部三个未被#clicked的。但是没有太多的选择 - 无论如何,悬停适用于所有三个div。我尝试过使用:而不是像hide()这样的其他函数,它工作得很好。那么这是一个CSS特殊问题?或者是mouseover/mouseout有问题?或者对我来说,就像是一个无能的傻瓜?
这里是我的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>
这里是jQuery代码:
// 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");
});