【发布时间】:2014-07-09 09:33:10
【问题描述】:
在 jQuery 中,如何将鼠标悬停在一张图片上并显示另一张图片?我知道 hover() 需要两个参数,但我不太清楚。有人请解释一下。
【问题讨论】:
标签: javascript jquery
在 jQuery 中,如何将鼠标悬停在一张图片上并显示另一张图片?我知道 hover() 需要两个参数,但我不太清楚。有人请解释一下。
【问题讨论】:
标签: javascript jquery
这是给你的小提琴。 http://jsfiddle.net/qYb5m/
我认为您正在寻找:
$('img').hover(
function() {
$(this).attr();
},
function() {
$(this).attr();
}
);
如您所见。 attr() 标记有一些可自定义的选项。
失望的猫是因为如果您不发布小提琴或代码,就好像您没有尝试过。
【讨论】:
$( ".your-img" ).hover(
function() { // this function will be executed when the mouse pointer enters your img
// try to show your second picture
}, function() { // when the mouse pointer leaves your img
// hide the second picture
}
);
您可以使用 css 将第二张图片设置为默认隐藏。
【讨论】: