CargoCollective 上的 jQuery 已过时 .hover/.mouseover

发布于 2025-01-08 12:02:45 字数 2519 浏览 0 评论 0原文

在 CargoCollective 上构建一个网站,但他们似乎使用 jQuery 1.4.2,这似乎没有我需要的功能。

所以,我想要的结果是这样的: http://jsfiddle.net/hendos43/a3hFh/ 1/

如果你因为某种原因看不到,如下所示,如果可以的话,请跳到代码后面:

目标:

员工照片库,将鼠标悬停在其上方时将显示 bio(单独的div),不会在mouseOut时消失(当鼠标 停止悬停在图像上),但会停留在那里,直到出现另一个图像 悬停在上方,触发下一个鼠标悬停事件。

我使用的代码是这样的:

JS:

 $(document).ready(function() {
    $('a[id^="link"]').mouseover(function() {
        $div = $('div#' + $(this).data('hide'));
        $div.siblings('[name^="people_bio"]').fadeOut(0).end().fadeIn(200, function() {
            if (!$div.is(':visible')) {
                $('nothing').fadeIn(40);
            }
        });
    });
});​

CSS:

#chris,
#patrick,
#jonathan,
#toby { position:absolute;
    left:285px;
    top:10px;
    border: 0px;
    background:none;
    padding: 5px; 
    width: 150px;
}

#holder { width:270px;
    position:absolute;
    top:10px;
    left:10px;}                

.hidden{
    display:none;
}
.shown{
    display:block;
}
​

HTML:

<div id="holder">
    <a id="link_chris" href="javascript:"  data-hide="chris"><img src="http://payload.cargocollective.com/1/2/77014/2272969/patrick%20crop.jpg"></a>
    <a id="link_patrick" href="javascript:"  data-hide="patrick"><img src="http://payload.cargocollective.com/1/2/77014/2272969/patrick%20crop.jpg"></a>
    <a id="link_jonathan" href="javascript:"  data-hide="jonathan"><img src="http://payload.cargocollective.com/1/2/77014/2272969/patrick%20crop.jpg"></a>
    <a id="link_toby" href="javascript:"  data-hide="toby"><img src="http://payload.cargocollective.com/1/2/77014/2272969/patrick%20crop.jpg"></a>
</div>

      <div name="people_bio" id="chris" class="hidden">chris' bio</div>
      <div name="people_bio" id="patrick" class="hidden">patrick's bio</div>
      <div name="people_bio" id="jonathan" class="hidden">jonathan's bio</div>
      <div name="people_bio" id="toby" class="hidden">toby's bio</div>
​

不幸的是,这似乎不起作用,大概是因为 1.4.4 中 jQuery 在该功能上的功能发生了一些变化,而 Cargo 使用 1.4.2?

使用 jsFiddle 中的测试选项,它可以在 1.4.4 中工作,但不能在 1.4.2 中工作,并且在自定义 HTML 部分中链接 1.7 似乎会破坏网站的其余部分,并使此功能正常工作,但 div 忽略了它们无论如何,CSS 风格的定位。也尝试过 .hover 具有相同的效果。

请问有人有解决办法吗?

(请忽略图像是相同的,这是说明性的)。

Building a site on CargoCollective, but it appears they use jQuery 1.4.2 which seems not to have the functionality I need.

So, the result I'm aiming for is this: http://jsfiddle.net/hendos43/a3hFh/1/

In case you can't see that for some reason, it's as follows, if you can, skip until after the code:

Aim:

Gallery of photos of employees which, when hovered over will display
bio (seperate div), which will not disappear onmouseOut (when mouse
stops hovering over image), but will stay there until another image is
hovered over, triggering the next mouseover event.

The code I have used is this:

JS:

 $(document).ready(function() {
    $('a[id^="link"]').mouseover(function() {
        $div = $('div#' + $(this).data('hide'));
        $div.siblings('[name^="people_bio"]').fadeOut(0).end().fadeIn(200, function() {
            if (!$div.is(':visible')) {
                $('nothing').fadeIn(40);
            }
        });
    });
});​

CSS:

#chris,
#patrick,
#jonathan,
#toby { position:absolute;
    left:285px;
    top:10px;
    border: 0px;
    background:none;
    padding: 5px; 
    width: 150px;
}

#holder { width:270px;
    position:absolute;
    top:10px;
    left:10px;}                

.hidden{
    display:none;
}
.shown{
    display:block;
}
​

HTML:

<div id="holder">
    <a id="link_chris" href="javascript:"  data-hide="chris"><img src="http://payload.cargocollective.com/1/2/77014/2272969/patrick%20crop.jpg"></a>
    <a id="link_patrick" href="javascript:"  data-hide="patrick"><img src="http://payload.cargocollective.com/1/2/77014/2272969/patrick%20crop.jpg"></a>
    <a id="link_jonathan" href="javascript:"  data-hide="jonathan"><img src="http://payload.cargocollective.com/1/2/77014/2272969/patrick%20crop.jpg"></a>
    <a id="link_toby" href="javascript:"  data-hide="toby"><img src="http://payload.cargocollective.com/1/2/77014/2272969/patrick%20crop.jpg"></a>
</div>

      <div name="people_bio" id="chris" class="hidden">chris' bio</div>
      <div name="people_bio" id="patrick" class="hidden">patrick's bio</div>
      <div name="people_bio" id="jonathan" class="hidden">jonathan's bio</div>
      <div name="people_bio" id="toby" class="hidden">toby's bio</div>
​

Unfortunately, this doesn't seem to work, presumably because there were some changes to jQuery's functioning on this feature in 1.4.4, and cargo uses 1.4.2?

Using the test options in jsFiddle, it works in 1.4.4, but not in 1.4.2, and linking up 1.7 in the custom HTML section appears to break the rest of the site, and make this feature work, but the divs ignore their CSS styled positioning anyway. Have also tried .hover with the same effects.

Anyone got any solutions, please?

(Please ignore that the images are the same, this is illustrative).

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

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

发布评论

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

评论(1

流绪微梦 2025-01-15 12:02:45

而不是使用 data

您可以使用 rel Demo< /a> 正在开发 1.3.2

Instead of using data you could use rel

Demo working on 1.3.2

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