我試圖讓一些div在mouseover上可見,但是我期望的代碼應該可以正常工作。也許我正在使用next()不正確?我在其他地方成功地使用了相同類型的東西,所以我有點不確定問題是什麼。使用.next()選擇具有特定類的div
代碼:
$(".clause").mouseenter(function() {
/* NOT WORKING */
$(this).next("div.drawer-arrow").css("display","block");
$(this).next("div.drawerBottom").css("display","block");
$(".clause").css("border-bottom-right-radius", "0px");
$(".clause").css("border-bottom-left-radius", "0px");
}).mouseleave(function(){
/* NOT WORKING */
$(this).next("div.drawer-arrow").css("display","none");
$(this).next("div.drawerBottom").css("display","none");
$(".clause").css("border-bottom-right-radius", "3px");
$(".clause").css("border-bottom-left-radius", "3px");
});
$(".clause").click(function() {
$(".clause").css("box-shadow", "none");
/* WORKING */
var tmp = $(this).next("div.drawer");
if(tmp.is(":hidden")) {
tmp.slideDown('2s');
$(this).css("box-shadow", "0px 3px 5px #AAA");
}
else {
tmp.slideUp('2s');
}
});
那麼,什麼不起作用之間使用
.nextAll()
當你不知道兄弟的數量? js小提琴例子工作正常。 PS:如果你給一個jsfiddle的鏈接,不要再發布你的代碼.. – tobspr我上次被一個mod告訴我應該總是發佈代碼,不管我是否有小提琴或不是:/ 基本上,它是當我將鼠標懸停在.clause div上時,不會顯示.drawerBottom和.drawer-arrow div。 – Jon
@TobiasSpringer - 只發佈一個小提琴的代碼通常是皺眉;他應該在問題中有一些代碼。但是,如果他鏈接到小提琴,他應該只發布少量的代碼。 –