0
我分裂的功能爲hoverintent和工作,但現在的div不隱藏,直到鼠標離開?jQuery hoverIntent - 當我分割函數時,我做錯了什麼?
我寫了這個工作正常,我是新來的jquery,你可能會告訴。
$("img.nexthover").hover(
function() { this.src = this.src.replace("_off", "_on");
},
function() { this.src = this.src.replace("_on", "_off");
});
$('#A,#B,#C,#D,#E,#F,#G,#H,#I,#J').addClass('nextHide');
$('.nextbuttonA').hover(function() {
$('#A.nextHide').fadeIn("slow");
$('#B,#C,#D,#E,#F,#G,#H,#I,#J.nextHide').fadeOut();
});
$('.nextbuttonB').hover(function() {
$('#B.nextHide').fadeIn("slow");
$('#A,#C,#D,#E,#F,#G,#H,#I,#J.nextHide').fadeOut();
});
$('.nextbuttonC').hover(function() {
$('#C.nextHide').fadeIn("slow");
$('#A,#B,#D,#E,#F,#G,#H,#I,#J.nextHide').fadeOut();
});
$('.nextbuttonD').hover(function() {
$('#D.nextHide').fadeIn("slow");
$('#A,#B,#C,#E,#F,#G,#H,#I,#J.nextHide').fadeOut();
});
$('.nextbuttonE').hover(function() {
$('#E.nextHide').fadeIn("slow");
$('#A,#B,#C,#D,#F,#G,#H,#I,#J.nextHide').fadeOut();
});
$('.nextbuttonF').hover(function() {
$('#F.nextHide').fadeIn("slow");
$('#A,#B,#C,#D,#E,#G,#H,#I,#J.nextHide').fadeOut();
});
$('.nextbuttonG').hover(function() {
$('#G.nextHide').fadeIn("slow");
$('#A,#B,#C,#D,#E,#F,#H,#I,#J.nextHide').fadeOut();
});
$('.nextbuttonH').hover(function() {
$('#H.nextHide').fadeIn("slow");
$('#A,#B,#C,#D,#E,#F,#G,#I,#J.nextHide').fadeOut();
});
$('.nextbuttonJ').hover(function() {
$('#I.nextHide').fadeIn("slow");
$('#A,#B,#C,#D,#E,#F,#G,#H,#J.nextHide').fadeOut();
});
$('.nextbuttonK').hover(function() {
$('#J.nextHide').fadeIn("slow");
$('#A,#B,#C,#D,#E,#F,#G,#H,#I.nextHide').fadeOut();
});
$('#A,#B,#C,#D,#E,#F,#G,#H,#I,#J').click(function(){
$('.nextHide').fadeOut();
});
要獲得hoverIntent工作我分裂這樣的功能:
$("img.nexthover").hover(
function() { this.src = this.src.replace("_off", "_on");
},
function() { this.src = this.src.replace("_on", "_off");
});
$('#A,#B,#C,#D,#E,#F,#G,#H,#I,#J').addClass('nextHide');
$('.nextbuttonA').hoverIntent(function() {
$('#A.nextHide').fadeIn("slow");
}, function() {
$('#B,#C,#D,#E,#F,#G,#H,#I,#J.nextHide').fadeOut();
});
$('.nextbuttonB').hoverIntent(function() {
$('#B.nextHide').fadeIn("slow");
}, function() {
$('#A,#C,#D,#E,#F,#G,#H,#I,#J.nextHide').fadeOut();
});
---etc----
但現在的格是不是隱藏,直到你離開按鈕像以前一樣? 對不起,如果這太新手了,我通過跳進來教自己...
檢查這些資源http://addyosmani.com/resources/essentialjsdesignpatterns/book/,http://www.slideshare.net/mathiasbynens/how-dry-impacts-javascript-performance-faster-javascript-execution-for -the懶惰開發商 – elclanrs 2012-04-24 23:32:47