Javascript jQuery maphilight使用;onclick";方法

Javascript jQuery maphilight使用;onclick";方法,javascript,jquery,javascript-events,Javascript,Jquery,Javascript Events,我使用的是maphilight插件,它适用于具有“usemap”属性的图像,并在鼠标上方的地图中勾勒出定义的区域 (此处的文档:) 我想用onClick事件而不是“onmouseover”触发hilight效果 我这样做: jQuery('.area').click(function(e){ e.preventDefault(); var data = jQuery(this).mouseout().data('maphilight') || {}; data.alwa

我使用的是maphilight插件,它适用于具有“usemap”属性的图像,并在鼠标上方的地图中勾勒出定义的区域

(此处的文档:)

我想用onClick事件而不是“onmouseover”触发hilight效果

我这样做:

jQuery('.area').click(function(e){
    e.preventDefault();

    var data = jQuery(this).mouseout().data('maphilight') || {};
    data.alwaysOn = !data.alwaysOn;
    jQuery(this).data('maphilight', data).trigger('alwaysOn.maphilight');

});
它可以正常工作,但我想在进行新的单击时删除hilight效果


有什么想法吗?

查看代码,它看起来像是事件
mouseout.maphilight
绑定到hilight地图,该地图将清除画布。我猜你可以触发那个事件来清除它。看起来您可能需要自己跟踪状态。

查找代码的这一部分并进行更改:

            $(map).trigger('alwaysOn.maphilight').find('area[coords]')
            .bind('mouseover.maphilight', mouseover)
            .bind('mouseout.maphilight', function(e) { clear_canvas(canvas); });
为此:

            $(map).trigger('alwaysOn.maphilight').find('area[coords]')
            .bind('click.maphilight', mouseover)
            .bind('mouseout.maphilight', function(e) { clear_canvas(canvas); });
将“mouseover”事件更改为“click”即可

<code> 
$('.mianchor').click(function(e) {
        e.preventDefault();
        var colorx = $(this).attr('title');
        var data = {};
        data.alwaysOn = !data.alwaysOn;
        data.stroke = 'none';
        data.strokeWidth = 0.0000001;
        data.strokeColor = colorx;
        data.fillColor = colorx; // Sample color
        data.fillOpacity = 1;
        $('#mapa').data('maphilight', data).trigger('alwaysOn.maphilight');         
    });