更新:06.29.10這是我目前使用的代碼。在搜索完Jquery文檔後,我非常接近。使用Jquery的多個或單獨的翻轉。嘲笑更好的解釋
$(document).ready(function(){
//Rollovers for circle buttons
$('img').hover(
function(){
this.src = this.src.replace("_org","_over");
},
function(){
this.src = this.src.replace("_over","_org");
});
//Disjointed rollover - on hover make circles use secondary hover (over2)
$(".genBtn80").hover(
function(){
$(".gen80circle").src = $(".gen80circle").src.replace("_org","_over2");
},
function(){
$(".gen80circle").src = $(".gen80circle").src.replace("_over2","_org");
});
});
因此,我有關於翻車的一切工作。我有以_org(正常狀態),_over(第一翻轉狀態)和_over2(第二翻轉狀態)爲後綴的圖像。我想現在我的問題在於針對不連貫的翻滾或二次翻轉的圓形按鈕。請參閱樣機鏈接。
下面的樣機正是我需要導航。 Click here for mockup
更新:06.30.10現在工作! 雖然......我不能發佈多個鏈接...... argh!我會通過測試鏈接發表評論。
我很好奇我如何使用數組和循環來簡化這個,但我不想成爲一個麻煩。我也很困惑,爲什麼上面的代碼從未工作。似乎我選擇了正確的元素,但src從未改變過。我確信我做錯了什麼,但我在這裏學習。 :)
$(document).ready(function(){
//Rollovers for circle buttons
$(".circleBtn").hover(
function(){
this.src = this.src.replace("_org","_over");
},
function(){
this.src = this.src.replace("_over","_org");
});
//Rollovers for navigation buttons
$(".navBtn").hover(
function(){
this.src = this.src.replace("_org","_over");
},
function(){
this.src = this.src.replace("_over","_org");
});
//Disjointed rollovers - use secondary rollover for circle imgs
$(".genBtn80").hover(
function(){
this.src = this.src.replace("_org","_over");
$("#janice_circle").attr("src", "images/janice_over2.gif");
$("#sugi_circle").attr("src", "images/sugi_over2.gif");
},
function(){
this.src = this.src.replace("_over","_org");
$("#janice_circle").attr("src", "images/janice_org.gif");
$("#sugi_circle").attr("src", "images/sugi_org.gif");
});
$(".genBtn70").hover(
function(){
this.src = this.src.replace("_org","_over");
$("#hatsuko_circle").attr("src", "images/hatsuko_over2.gif");
$("#satoko_circle").attr("src", "images/satoko_over2.gif");
},
function(){
this.src = this.src.replace("_over","_org");
$("#hatsuko_circle").attr("src", "images/hatsuko_org.gif");
$("#satoko_circle").attr("src", "images/satoko_org.gif");
});
$(".genBtn60").hover(
function(){
this.src = this.src.replace("_org","_over");
$("#noriko_circle").attr("src", "images/noriko_over2.gif");
$("#yuki_circle").attr("src", "images/yuki_over2.gif");
},
function(){
this.src = this.src.replace("_over","_org");
$("#noriko_circle").attr("src", "images/noriko_org.gif");
$("#yuki_circle").attr("src", "images/yuki_org.gif");
});
$(".genBtn50").hover(
function(){
this.src = this.src.replace("_org","_over");
$("#ritsuko_circle").attr("src", "images/ritsuko_over2.gif");
$("#yuka_circle").attr("src", "images/yuka_over2.gif");
},
function(){
this.src = this.src.replace("_over","_org");
$("#ritsuko_circle").attr("src", "images/ritsuko_org.gif");
$("#yuka_circle").attr("src", "images/yuka_org.gif");
});
$(".genBtn40").hover(
function(){
this.src = this.src.replace("_org","_over");
$("#christina_circle").attr("src", "images/christina_over2.gif");
$("#chiharu_circle").attr("src", "images/chiharu_over2.gif");
},
function(){
this.src = this.src.replace("_over","_org");
$("#christina_circle").attr("src", "images/christina_org.gif");
$("#chiharu_circle").attr("src", "images/chiharu_org.gif");
});
$(".genBtn30").hover(
function(){
this.src = this.src.replace("_org","_over");
$("#haruko_circle").attr("src", "images/haruko_over2.gif");
$("#shiho_circle").attr("src", "images/shiho_over2.gif");
},
function(){
this.src = this.src.replace("_over","_org");
$("#haruko_circle").attr("src", "images/haruko_org.gif");
$("#shiho_circle").attr("src", "images/shiho_org.gif");
});
$(".genBtn20").hover(
function(){
this.src = this.src.replace("_org","_over");
$("#aoi_circle").attr("src", "images/aoi_over2.gif");
$("#tomoko_circle").attr("src", "images/tomoko_over2.gif");
$("#miho_circle").attr("src", "images/miho_over2.gif");
},
function(){
this.src = this.src.replace("_over","_org");
$("#aoi_circle").attr("src", "images/aoi_org.gif");
$("#tomoko_circle").attr("src", "images/tomoko_org.gif");
$("#miho_circle").attr("src", "images/miho_org.gif");
});
});
下面是測試鏈接:http://www.ericsbowman.com/storage/cwac/index_test.html – ESB 2010-06-30 18:51:10