Jquery: Exclude a contained element
I'd like to mouseoverize the div but not the img
开发者_运维技巧$('div').mouseover(go_truc);
How can I do that ?
Handle the mouseenter
event, but do nothing if ($(e.target).is('img'))
.
Then, handle the <img>
element's mouseenter
event, and undo the effect.
With
function do_trucs() {
...
}
function do_machins() {
...
return (false);
}
$('div').mouseover(do_trucs);
$('div img').mouseover(do_machins);
It's working, but is it the simplest/best solution ?
(Anyway I need to handle the img.mouseover for other purpose)
精彩评论