mouseover和mouseout的一些复杂组成 [英] A little complex compose of mouseover and mouseout
问题描述
如何更改此功能:
$('#myContent').live('mouseover mouseout', function(event){
if ( event.type == "mouseover" ) {
$('#editContent').show();
} else {
$('#editContent').hide();
}
});
如果我希望在$('#myContent')
上的鼠标悬停时显示$('#editContent')
,但是只有当$('#myContent')
有事件鼠标悬停而$('#editContent')
有鼠标悬停时,它才应隐藏?
if i want $('#editContent')
to be show on mouseover on $('#myContent')
, but then it should be hiden only if $('#myContent')
has event mouseover and $('#editContent')
has mouseover?
推荐答案
一个问题,您是否必须使用事件"live"?由于我不知道您的HTML是如何实现的,因此我可以做一些假设.
One question, do you have to use the event "live"? Since I don't know how your HTML is implemented, I can just assume things.
以上是一个如何实现此目的的示例.因为我假设您没有动态地附加"editContent"和"myContent",所以我改用事件"hover".
Above is an example how you can achieve this. As I assume you do not append "editContent" and "myContent" dynamically, I use event "hover" instead.
希望有帮助!
这篇关于mouseover和mouseout的一些复杂组成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!