我有以下jQuery代碼(我的第一個自制jQuery代碼,所以不要太在意:))。 Eveything完全適用於我第一次使用切換:
- 我點擊右側的撥動,顯得#內容移動,離開切換。
- 我點擊左側切換,#內容向後移動,右側切換出現。 (一切都回到起始位置)。
但之後,我的右鍵不再可點擊(它確實出現)。我想一遍又一遍地做同樣的事情(點擊右鍵切換,#內容移動等等)。但用我目前的代碼,我只能做一次這個動畫。
任何人都可以幫助我:)?
感謝提前:)
//starting values
$(".rowToggleL").off('click');
$(".rowToggleR").on('click');
//Right Toggle
$(".rowToggleR").click(function() {
// make Toggle Right unclickable, make Toggle Left clickable
$(".rowToggleR").off('click');
$(".rowToggleL").on('click');
//animate contentbox
$("#content").animate({
left: "-=300" // animate to the right
}, 800,
// Animation complete. Make Toggle Right invisible, make Toggle Left visible
function() {
$(".rowToggleR").css("display", "none");
$(".rowToggleL").css("display", "inline");
});
});
//Left Toggle
$(".rowToggleL").click(function() {
// make Toggle Left unclickable, make Toggle Right clickable
$(".rowToggleL").off('click');
$(".rowToggleR").on('click');
//animate contentbox
$("#content").animate({
left: "+=300" // animate to the right
}, 800,
// Animation complete. Make Toggle Left invisible, make Toggle Right visible.
function() {
$(".rowToggleL").css("display", "none");
$(".rowToggleR").css("display", "inline");
});
});
工程!非常感謝! :)! – Frank