目前我正在尝试hover
为图像映射实现效果。我在悬停时交换图像,替换图像的地图部分填充了“悬停”颜色。
<map name="Map">
<area id="france" shape="poly" coords="98,133,123,129,151,116,165,129,188,140,181,156,175,167,177,176,181,195,171,203,153,201,145,209,110,196,119,171,110,149,94,141" href="/page/france">
<area id="england" shape="poly" coords="94,119,114,115,139,116,150,100,130,69,117,75,119,89,115,106" href="/page/england">
<area id="wales" shape="poly" coords="118,87,112,107,99,100,109,86" href="/page/wales">
// many more areas //
</map>
jQuery
$('#england').hover(
function() {
$('img').attr('src', '/lib/img/layout/map-en.gif');
},
function() {
$('img').attr('src', '/lib/img/layout/map.gif');
}
);
它工作得很好。问题是我的图像地图中有很多区域。jQuery有没有办法从链接中获取href的最后一部分并将其放入动态工作变量中?
示例逻辑:
var identifier = area/href/this
$(identifier).hover(
function() {
$('img').attr('src', '/lib/img/layout/map-'+identifier+'.gif');
},
function() {
$('img').attr('src', '/lib/img/layout/map.gif');
}
);