绑定 - 鼠标悬停在 ul 列表上

发布于 2024-12-05 02:26:02 字数 713 浏览 1 评论 0原文

我遇到这样的情况:

<ul id="country_list"onmouseover="cl();">

function cl(){ 
// something to do 
}

该功能可以运行但没有声音。

所以我这样做:

$('#country_list').bind('mouseover', function () { // do what you want to do on mouse over });

但是功能不起作用!

对于解决方案,我看到了这个问题 My mouseover, mouseleave does not work 我已经尝试过所有的建议,但什么也没有!

为什么???

在名为 变量和 jquery 的问题中:如何捕获值并使用它们(第 3 部分),您可以找到 function cl() 的所有代码。

谢谢

I have this situation:

<ul id="country_list"onmouseover="cl();">

function cl(){ 
// something to do 
}

This function goes but not sounds.

So I do this:

$('#country_list').bind('mouseover', function () { // do what you want to do on mouse over });

but the function doesn't work!!!

For the solution I have seen this question My mouseover, mouseleave doesnt work and I have tried all the suggestions, but nothing !

Why???

In the question called variables and jquery: how capture value and use them (part 3) you can find all my codex for the function cl().

thanks

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

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

发布评论

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

评论(1

2024-12-12 02:26:02

您使用 mouseover() 有什么具体原因吗?我会推荐 hover()

$('#country_list').hover(function () {
    // Do something
    alert('Im doing something!');
});

进一步:

$('#country_list').hover(function () {
    // Do something on mouseover
    alert('Cursor landed on the object');
}, function () {
    // Do something on mouseout
    alert('Cursor left the object');
});

A 面注意:如果这不起作用,那么问题很可能出在其他地方。也许您忘记了一般情况下包含 jQuery,或者某个地方存在基本的 JS 问题。

Is there any specific reason you are using mouseover()? I would recommend hover():

$('#country_list').hover(function () {
    // Do something
    alert('Im doing something!');
});

Further more:

$('#country_list').hover(function () {
    // Do something on mouseover
    alert('Cursor landed on the object');
}, function () {
    // Do something on mouseout
    alert('Cursor left the object');
});

A side note: If this doesn't work, then most likely the problem is somewhere else. Maybe you forgot to include jQuery in general or there is a fundamental JS issue somewhere.

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