Jquery:排除包含的元素

发布于 2024-09-01 14:51:51 字数 108 浏览 2 评论 0原文

Chouette

我想将鼠标悬停在 div 上而不是 img

$('div').mouseover(go_truc);

我该怎么做?

Chouette

I'd like to mouseoverize the div but not the img

$('div').mouseover(go_truc);

How can I do that ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

滿滿的愛 2024-09-08 14:51:51

处理 mouseenter 事件,但 if ($(e.target).is('img')) 不执行任何操作。

然后,处理 元素的 mouseenter 事件,并撤消效果。

Handle the mouseenter event, but do nothing if ($(e.target).is('img')).

Then, handle the <img> element's mouseenter event, and undo the effect.

(り薆情海 2024-09-08 14:51:51

function do_trucs() {
  ...
}

function do_machins() {
  ...
  return (false);
}

$('div').mouseover(do_trucs);
$('div img').mouseover(do_machins);

可以工作,但它是最简单/最好的解决方案吗?

(无论如何,我需要处理 img.mouseover 用于其他目的)

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)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文