2012-01-16 102 views
0

我剛剛將jQuery Maphighlight添加到我的應用程序中,查看了文檔,我努力使圖片上的每個圖形在點擊時切換突出顯示的狀態。使用jQuery maphighlight插件切換功能

我可以得到一個形狀切換而不是倍數

這適用於一個形狀:

$(function() { 
    $('.map').maphilight(); 

    $('#north').click(function(e) { 
     e.preventDefault(); 
     var data = $('#north').mouseout().data('maphilight') || {}; 
     data.alwaysOn = !data.alwaysOn; 
     $('#north').data('maphilight', data).trigger('alwaysOn.maphilight'); 
    }); 
    }); 

我怎麼能在這擴大到覆蓋所有的形狀?

非常感謝您的幫助。

回答

1

改變jQuery選擇,像這樣:

$(function() { 

    $('.map').maphilight(); 

    // classname optional 
    $('.map area.classname').click(function(e) { 
     e.preventDefault(); 
     var data = $(this).mouseout().data('maphilight') || {}; 
     data.alwaysOn = !data.alwaysOn; 
     $(this).data('maphilight', data).trigger('alwaysOn.maphilight'); 
    }); 
    });