需要添加悬停意图吗?

发布于 2024-09-02 01:53:14 字数 1248 浏览 1 评论 0原文

我真的被困住了。 基本上我对 jquery 完全陌生,但需要在鼠标悬停时添加某种计时器,这样如果鼠标在整个页面上移动,页面就不会变得混乱。 这是我的脚本.. 无论如何我可以轻松实现它吗?

<script>
jQuery('cc').mouseover(function () {  
$("squareleft3").hide();  
$("twitter").hide();  
$("facebook").hide();  
$("squareright").hide();  
$("getintouch").hide();  
$("getintouch2").hide();  
$("getintouch3").hide();  
$("vicarimage").hide();  
$("squaredown2").hide();  
$("squareleft2").hide();  
$("one").hide();  
$("whatis").hide();  
$("squaredown").hide();  
$("whoweare").hide();  
if ($("whoweare:first").is(":hidden"))   
    if ($("squaredown:first").is(":hidden"))   
    if ($("squareleft3:first").is(":hidden")) { 
    if ($("twitter:first").is(":hidden"))  
if ($("squareright:first").is(":hidden"))  
if ($("getintouch:first").is(":hidden"))
if ($("getintouch2:first").is(":hidden")) 
if ($("getintouch3:first").is(":hidden"))
if ($("vicarimage:first").is(":hidden"))
if ($("squaredown2:first").is(":hidden"))
if ($("squareleft2:first").is(":hidden"))
if ($("one:first").is(":hidden"))
if ($("whatis:first").is(":hidden"))
jQuery('getinvolved').fadeIn(); 
jQuery('squareleft').slideToggleWidth();
} else {
$("squareleft").hide();
$("getinvolved").hide();
} } );
</script>

干杯。

I'm really stuck.
Basically i'm totally new to jquery, but need to add some kind of timer on mousover so that the page doesn't get messed up if the mouse goes all over the page.
here's my script..
anyway i can easily implement it?

<script>
jQuery('cc').mouseover(function () {  
$("squareleft3").hide();  
$("twitter").hide();  
$("facebook").hide();  
$("squareright").hide();  
$("getintouch").hide();  
$("getintouch2").hide();  
$("getintouch3").hide();  
$("vicarimage").hide();  
$("squaredown2").hide();  
$("squareleft2").hide();  
$("one").hide();  
$("whatis").hide();  
$("squaredown").hide();  
$("whoweare").hide();  
if ($("whoweare:first").is(":hidden"))   
    if ($("squaredown:first").is(":hidden"))   
    if ($("squareleft3:first").is(":hidden")) { 
    if ($("twitter:first").is(":hidden"))  
if ($("squareright:first").is(":hidden"))  
if ($("getintouch:first").is(":hidden"))
if ($("getintouch2:first").is(":hidden")) 
if ($("getintouch3:first").is(":hidden"))
if ($("vicarimage:first").is(":hidden"))
if ($("squaredown2:first").is(":hidden"))
if ($("squareleft2:first").is(":hidden"))
if ($("one:first").is(":hidden"))
if ($("whatis:first").is(":hidden"))
jQuery('getinvolved').fadeIn(); 
jQuery('squareleft').slideToggleWidth();
} else {
$("squareleft").hide();
$("getinvolved").hide();
} } );
</script>

Cheers.

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

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

发布评论

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

评论(2

醉城メ夜风 2024-09-09 01:53:14

获取 hoverIntent 的副本。

将其链接到您的 HEAD 区域。

使用 hoverIntent() 而不是 mouseOver()

还有各种其他选项可以调整计时阈值(请参阅文档)。

正如其他人指出的那样,您的代码到处都是。但hoverIntent确实解决了计时问题。

Grab a copy of hoverIntent.

Link it in in your HEAD region.

Instead of mouseOver(), use hoverIntent()

There are various additional options to tune the timing thresholds (see documentation).

As others have pointed out, your code is all over the place. But hoverIntent does address the timing problem.

谎言 2024-09-09 01:53:14

您指的是所有 $("getintouch2").hide(); 类或 ID 吗? getintouch2 是一个类吗?如果是这样,它前面需要有一个句点,或者如果它是一个 id,则前面需要有一个哈希值。像这样: $(".getintouch2").hide(); 对于类,或者 $("#getintouch2").hide(); 如果它是 ID。

我认为使用 hover 而不是 mouseover 会更符合您的需求,然后我认为您的 if 语句有点混乱,如果使用多个 if,您需要将 & ;&在它们之间将它们链接成一个,我可能说错了,但我读了更多 jquery 教程,因为整件事有点古怪。祝你好运,我花了一段时间来学习 Jquery、大量的尝试和错误以及大量的 Stack Overflow 问题。

如果您使用较小的代码片段,人们通常会帮助您编写代码,特别是如果您有一个关于您要在 http://www.jsfiddle.com
当人们使用 Jsfiddle 时,可以更快、更轻松地为他们提供帮助。因此,我会将您的代码分解为一个小示例,并尝试一次解决一个问题,如果您有一个 if 语句不起作用,则其他语句也不起作用,但是您发布了如此多的代码,这对于大多数人来说可能是难以承受的,否则如果您将其发布到 jsfiddle 或者将其缩小得多,他们会用正确的代码回答您。所以一次完成一件事情,Stack Overflow 是天赐之物,记住,我在这里学到了很多东西,我得到了很多帮助,人们投入了很多时间来帮助别人,这几乎是鼓舞人心的。让我也想帮助其他人。

哦,hoverIntent 是我经常使用的一个很棒的插件,它使得如果用户在屏幕上移动鼠标,也许从屏幕底部到导航,它不会激活所有的鼠标悬停/悬停效果,他们必须将鼠标放慢到一定的速度才能发生效果,这是完美的。

are all of $("getintouch2").hide(); classes or ID's your referring to? is getintouch2 a class? if so, it needs to have a period in front of it, or a hash before it if it's an id. like so: $(".getintouch2").hide(); for class, or $("#getintouch2").hide(); if it's an ID.

I think using hover instead of mouseover would be more what you want, and then your if statements i think are kinda messed up, if using multiple if's, you need to put && between them to link them into one, i probably said that wrong, but i'd read more jquery tutorials because the whole thing is kind of outa-wack. Best of luck, it took me awhile to learn Jquery, lots of trial and error, and lots of Stack Overflow questions.

People will usually help you with code if you use smaller pieces of code, and especially if you have a small example of what you're trying to do on http://www.jsfiddle.com
it's so much quicker and easier to help people when they use Jsfiddle. So I would break your code down into a little example, and try to get the kinks worked out one piece at a time, if you have one if statement that's not working, non of the other will either, but you posted so much code that it's probably overwhelming to most people that would otherwise answer you with the correct code if you had posted it to jsfiddle or if you had made it much smaller. So work it out one piece at a time, and Stack overflow is a godsend, remember that, i've learned so much here and i've gotten so much help, people dedicate so much time to helping others, it's almost inspirational.. makes me want to help other people too.

Oh, and hoverIntent is an awesome plugin that I use often, it makes it so if the person moves their mouse across the screen, maybe from the bottom of the screen up to the navigation, it wont activate ALL of the mouseover/hover effects, they have to slow their mouse down to a certain speed in order for the effect to happen, it's perfect.

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