2012-01-16 41 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'); 
    }); 
    });