2014-03-06 42 views
0

我正在創建一個簡單的網頁作爲我的計算機任務的一部分,並且我決定在其中包含一些jQuery。它非常簡單的jQuery,以下列出:jQuery-限制動畫數量

$(document).ready(function() { 
$("#dialog").dialog({ 
    modal: true, 
    height: 410, 
    width: 500, 
    resizeable: true, 
    }); 
$('#credits').hide(); 
$('#doctor_seuss_info').hide(); 
$('#title').hover(function() { 
    $('#credits').show('slow') 
    }); 
$('#title').mouseleave(function() { 
    $('#credits').hide('slow'); 
    }); 
$('#doctor_seuss_title').hover(function(){ 
    $('#doctor_seuss_info').show('slow'); 
    }); 
$('#doctor_seuss_title').mouseleave(function(){ 
    $('#doctor_seuss_info').hide('slow'); 
    }); 
$('#other_poems').accordion(); 
$('#doctor_seuss_fish').click(function() { 
    $(this).animate({'marginLeft' : '-60em'}, 5000); 
    }); 
}); 

我已經是該網站是有點難以瀏覽,因爲如果您移動鼠標太快一切都將圍繞移動的問題。我將如何去增加對象移動次數的限制?

+0

也許你只是尋找'.stop()' –

回答

0

應該會更好:

懸停beeing爲的mouseenter /鼠標離開的簡寫,你的代碼不能正常工作,你希望它

$(document).ready(function() { 
    $("#dialog").dialog({ 
     modal: true, 
     height: 410, 
     width: 500, 
     resizeable: true, 
    }); 
    $('#credits, #doctor_seuss_info').hide(); 
    $('#title').hover(function() { 
     $('#credits').stop().toggle('slow') 
    }); 

    $('#doctor_seuss_title').hover(function() { 
     $('#doctor_seuss_info').stop().toggle('slow'); 
    }); 

    $('#other_poems').accordion(); 
    $('#doctor_seuss_fish').click(function() { 
     $(this).stop().animate({ 
      'marginLeft': '-60em' 
     }, 5000); 
    }); 
});