jquery 工具 - 选项卡鼠标悬停 - 添加链接

发布于 2024-08-19 20:30:15 字数 630 浏览 6 评论 0原文

我喜欢这个工具,当将鼠标移动到像素上时显示文本:

http://flowplayer .org/tools/demos/tabs/mouseover.htm

现在,当鼠标单击其中一个像素时,我尝试打开一个链接。我尝试了这种方式:

original: <'img src="http://static.flowplayer.org/img/commerce/commercial.png" alt="Commercial version" />'

adding link: <'a title="Mylink" href="http://mylink.com" target="_blank"><'img src="http://static.flowplayer.org/img/commerce/free.png" alt="Free version" /></a>''

[插入'仅显示源。]

使用此链接,鼠标悬停不再起作用。有人知道那里可以做什么吗?

预先感谢您的帮助!

I love this tool to show text when moving the mouse over the pix:

http://flowplayer.org/tools/demos/tabs/mouseover.htm

Now I'm trying to open a link, when one of the pix is clicked by the mouse. I tried this way:

original: <'img src="http://static.flowplayer.org/img/commerce/commercial.png" alt="Commercial version" />'

adding link: <'a title="Mylink" href="http://mylink.com" target="_blank"><'img src="http://static.flowplayer.org/img/commerce/free.png" alt="Free version" /></a>''

[The ' are inserted to show the source only.]

With this link mouseover is no longer working. Does somebody know what to do there?

Thank in advance for any help!

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

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

发布评论

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

评论(4

红颜悴 2024-08-26 20:30:15

我没有使用过这个 jQuery 工具。但我认为该工具需要结构

<div id="products">
    <img src="http://static.flowplayer.org/img/commerce/free.png" alt="Free version" />
    <img src="http://static.flowplayer.org/img/commerce/commercial.png" alt="Commercial version" />
    <img src="http://static.flowplayer.org/img/commerce/multidomain.png" alt="Multidomain version" />
</div>

该工具将在 div 中查找 img (同样,我没有看到代码,所以这是一个假设)。许多 jQuery 插件需要特定的格式。

我会这样做:

 <div id="products">

        <img src="http://static.flowplayer.org/img/commerce/free.png" alt="Free version" id="image1" />
        <img src="http://static.flowplayer.org/img/commerce/commercial.png" alt="Commercial version" id="image2" />
        <img src="http://static.flowplayer.org/img/commerce/multidomain.png" alt="Multidomain version" id="image3" />
    </div>

将 id 添加到每个标签。我已经尝试过了,似乎并没有破坏该插件。 (请原谅糟糕的命名约定:))

然后使用javascript将图像的点击绑定到重定向:

$("#image1").click(function() {
    window.location = 'http://www.google.co.za';
});

$("#image2").click(function() {
    window.location = 'http://www.google.co.za/somwhereelse';
});

$("#image3").click(function() {
    window.location = 'http://www.google.co.za/helloworld';
});

希望这有助于

编辑

要回答您的问题以在页面加载时显示第二个图像的内容,我有以下解决方案。这对我来说有点像一种解决方法,但希望它能起作用。

在页面加载时,Flowplayer 会使用内联样式隐藏除第一个图像之外的所有图像。

所以我们需要做的就是从第一张图片中删除这个样式,并将其添加到第二张图片中。请记住,这只能在页面加载时发生一次,因此您需要将其添加到 document.ready 函数中。

//make the display attribute of the style none. This will render it invisible
$("#free").css('display','none');
//make the display attribute of the style block (as what Flowplayer does)
$("#commercial").css('display','block');

重要的是,这只发生一次,然后 FlowPlayer 功能会在鼠标悬停时正常​​启动。

I haven't used this jQuery tool. But I would think that the tool would require the structure

<div id="products">
    <img src="http://static.flowplayer.org/img/commerce/free.png" alt="Free version" />
    <img src="http://static.flowplayer.org/img/commerce/commercial.png" alt="Commercial version" />
    <img src="http://static.flowplayer.org/img/commerce/multidomain.png" alt="Multidomain version" />
</div>

The tool would look for an img within a div (again, I haven't seen the code, so this is an assumption). Lots of jQuery plugins require a certain format.

I would do this:

 <div id="products">

        <img src="http://static.flowplayer.org/img/commerce/free.png" alt="Free version" id="image1" />
        <img src="http://static.flowplayer.org/img/commerce/commercial.png" alt="Commercial version" id="image2" />
        <img src="http://static.flowplayer.org/img/commerce/multidomain.png" alt="Multidomain version" id="image3" />
    </div>

Adding the ids to each tag. I've tried it and it doesn't appear to break the plugin. (Excuse the terrible naming convention :))

Then bind the click of the images to a redirect using javascript:

$("#image1").click(function() {
    window.location = 'http://www.google.co.za';
});

$("#image2").click(function() {
    window.location = 'http://www.google.co.za/somwhereelse';
});

$("#image3").click(function() {
    window.location = 'http://www.google.co.za/helloworld';
});

Hope that helps

EDIT

To answer your question to show the content of the second image on page load, I have the following solution. This feels a bit like a workaround to me, but hopefully it works.

On your pageload what happens is that flowplayer hides all the images except the first one using inline styles.

So what we need to do is remove this style from the first image, and add it to the second image. Remember this must only happen once on page load so you will need to add it to the document.ready function.

//make the display attribute of the style none. This will render it invisible
$("#free").css('display','none');
//make the display attribute of the style block (as what Flowplayer does)
$("#commercial").css('display','block');

It's important that this only happens once, and then the FlowPlayer functionality kicks in normally on mouseovers.

分分钟 2024-08-26 20:30:15

最简单的解决方案:确保所有图像都包含在中。即:

<div id="products"> 
    <a href="#"><img src="http://static.flowplayer.org/img/commerce/free.png" alt="Free version" /></a>
    <a href="#"><img src="http://static.flowplayer.org/img/commerce/commercial.png" alt="Commercial version" /></a>
    <a href="#"><img src="http://static.flowplayer.org/img/commerce/multidomain.png" alt="Multidomain version" /></a>
</div> 

这很好用;我刚刚尝试过。我假设 jQuery 工具选项卡仅在您指定的容器的所有子项都是同一类型时才起作用。

编辑:是的,它似乎只适用于它遇到的第一种类型的标签。例如,如果您将前两个链接放在 中而不是第三个链接中,则鼠标悬停仅适用于前两个链接。

SIMPLEST solution: make sure all the images are wrapped in <a>. i.e.:

<div id="products"> 
    <a href="#"><img src="http://static.flowplayer.org/img/commerce/free.png" alt="Free version" /></a>
    <a href="#"><img src="http://static.flowplayer.org/img/commerce/commercial.png" alt="Commercial version" /></a>
    <a href="#"><img src="http://static.flowplayer.org/img/commerce/multidomain.png" alt="Multidomain version" /></a>
</div> 

This works fine; I just tried it. I'm assuming that jQuery Tools Tabs only works if all the children of the container you specify are the same type.

EDIT: yes, it seems to work only with the first type of tag it encounters. e.g. if you put the first two links in <a> and not the third, mouseover only works for the first two.

鲸落 2024-08-26 20:30:15

我认为你需要忘记这个插件,因为它实际上并不意味着做你想做的事。
该插件用于创建选项卡,您显示的实际上是另一件夹克中的选项卡。
选项卡不会打开网址,它们会显示窗格的内容。

您需要的是某种工具提示。以下是开始的工具提示列表: http://speckyboy.com/2009/09/16/25-useful-jquery-tooltip-plugins-and-tutorials/

I think you need to forget this plugin, 'cause it actually isn't meant to do what you want.
This plugin is for creating tabs, and what you show are actually tabs in another jacket.
And tabs don't open urls, they show the content of their pane.

What you need is some sort of tooltip. Here is a list of tooltips to start with: http://speckyboy.com/2009/09/16/25-useful-jquery-tooltip-plugins-and-tutorials/

以往的大感动 2024-08-26 20:30:15

如果您将带有图像的链接粘贴在跨度内,它将起作用。

<span><a href="http://yourlink"><IMG src="./jQuery Tools standalone demo_files/free.png" alt="Free version" class=""></a></span>

即使您不链接所有图像,您也必须将所有图像粘贴在一个跨度中,以便结构相同。

这样做的好处是它将被索引为真正的链接,而 javascript 方法则不会。

If you stick the link with the image inside a span it'll work.

<span><a href="http://yourlink"><IMG src="./jQuery Tools standalone demo_files/free.png" alt="Free version" class=""></a></span>

You have to have to stick all the images in a span so the structure is the same, even if you don't link all the images.

The benefit of doing it this way is that it will be indexed as a real link, a javascript approach will not.

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