2011-02-10 53 views

回答

0

我想你可以通過觸發您現有的點擊處理程序做到這一點很簡單:

$('#map-previous').click(function(){ 
    var currentAreaIndex = $('area.current').index(); 
    var prevAreaIndex = currentAreaIndex - 1; 

    // If .eq() gets -1 as a parameter it retrieves the last item 
    // You could disable the link if you didn't like that behavior  
    $('area').eq(prevAreaIndex).click(); 
}); 

$('#map-next').click(function(){ 
    var currentAreaIndex = $('area.current').index(); 
    var nextAreaIndex = currentAreaIndex + 1; 

    var $areas = $('area'); 

    // Here you'll need to manually handle the wrap-around case  
    if (nextAreaIndex > $areas.length){ 
    nextAreaIndex = 0; 
    } 

    $('area').eq(nextAreaIndex).click(); 
}); 

您可以通過改變順序控制區域的順序的HTML ...

相關問題