我尝试在单击图像映射的某个区域时重置变量(更新图像的SRC值),以便当用户将鼠标悬停在图像映射的另一个区域上时,悬停函数调用不同的图像。
我有一个名为“状态”的变量,可以直接设置。这是单击区域时要重置的变量。
var state = "path/to/images/feed1.png";
我有几个函数涉及hover()和click()。
$("#Map area").click(
function () {
var button = $(this).attr("id");
// here is where i want to reset the 'state' variable
var state = "path/to/images/" + button + ".png";
alert("you clicked "+button+" hello");
return false;
}
);
$("#Map area").hover(
function () {
var button = $(this).attr("id");
over("path/to/images/" + button + ".png");
},
function () {
off();
});
以及这些函数调用的一些函数:
function over(image) {
$("#feednavImg").attr("src", image);
}
function off() {
$("#feednavImg").attr("src", state);
}