我使用 jquery 创建了一个接受复选框(如在 stackoverflow.com 中)。我使用了 maphilight.js插件。
具体来说,我创建了一个图像映射,定义了我的区域,并应用了插件,以便在鼠标悬停时突出显示该区域,在单击时更改颜色。
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
<script type="text/javascript" src="../jquery.maphilight.js"></script>
<script>$(function() {
$('#star,#starlink2').click(function(e) {
e.preventDefault();
var data = $('#star').mouseout().data('maphilight') || {};
data.alwaysOn = !data.alwaysOn;
$('#star').data('maphilight', data).trigger('alwaysOn.maphilight');
});
});</script>
HTML 方面:
<img src="image.png" width="300" height="301" class="map" usemap="#features">
<map name="features">
<area id="star" shape="poly" coords="78,83,70,100,52,104,64,115,61,133,78,124,94,133,91,116,104,102,87,101,79,88" href="#" alt="star" class="group" data-maphilight='{"strokeColor":"0000ff","strokeWidth":5,"fillColor":"ff0000","fillOpacity":0.6}'>
</map>
我确信我可以用另一种方法更好地做到这一点,而不是使用 maphighlight.js,也许使用我不知道的 HTML 库之一。问题是我找不到要放入搜索中的关键字以找到最佳方法。
非常感谢您的建议。