2011-02-10 9 views
1

jsFiddleの例でわかるように、jQuery Map Highlightプラグインを使用したダイアグラムでは、ユーザーがダイアグラムの異なる部分をクリックして、左。jQueryマップハイライトプラグインにPrevious/Next機能を追加する

今、ダイアグラムと対話する唯一の方法は、ダイアグラムをクリックすることです。私は、ユーザーにそれを制御するために前のボタンと次のボタンを押す能力を与えたいと思います。私はそれについてどうやって行くのか分かりません。

任意の助けいただければ幸いです:あなたは順序を変更することにより、領域の順序を制御することができ

$('#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(); 
}); 

http://jsfiddle.net/keith/jkLH7/1/

答えて

0

は、私はあなたがあなたの既存のクリックハンドラをトリガすることによって、かなり単純にこれを行うことができると思いますHTMLの...

関連する問題