我试图在单击图像映射的区域时重置变量(更新图像的src值),以便当用户将鼠标悬停在图像映射中的另一个区域时,悬停函数调用不同的图像.
我有一个名为"状态"的变量,我立即设置.这是我想在单击某个区域时重置的变量.
var state = "path/to/images/feed1.png";
Run Code Online (Sandbox Code Playgroud)
我有几个涉及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();
});
Run Code Online (Sandbox Code Playgroud)
以及这些函数调用的一些函数:
function over(image) {
$("#feednavImg").attr("src", image);
}
function off() {
$("#feednavImg").attr("src", state);
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
12628 次 |
| 最近记录: |