【发布时间】:2012-07-09 19:09:01
【问题描述】:
我正在使用 this syntax option 进行 jquery 悬停。
这是我的代码:
$('mySelector')
.hover(
function(){
$(this).html('<img src="images/myImage2.png" height="23" width="24" />');
},
function(){
$(this).html('<img src="images/myImage1.png" height="23" width="24" />');
}
);
mySelector 引用的元素的原始文本是 mouseleave 选项 - $(this).html('<img src="images/myImage1.png" height="23" width="24" />');
第一个处理程序,用于 mouseenter/mouseover,工作正常。但是第二个处理程序,用于 mouseleave/mouseout(应该恢复原始图像),永远不会执行。当我在firebug中跟踪它时,触发了mouseover事件,但没有到达第二个“function()”。
编辑:
为了清楚起见,我的 html 代码是这样的:
<div id="results">
<span class="imageClass"><img src="images/myImage1.png" height="23" width="24" /</span>
</div>
然后我的选择器是"#results .imageClass"
【问题讨论】:
-
你能在 jsfiddle 上重现这个问题吗?
-
检查我发布的小提琴
-
@zerkms - 我现在似乎无法使用 jsfiddle,当我这样做时,我会尝试重现它。
-
@froadie 你能发布所有相关元素的 HTML 结构吗?
标签: jquery hover mouseevent