我可以让这个 jQuery 工具提示在我的光标悬停在它上面时保持打开状态吗?

发布于 2024-10-12 23:50:08 字数 250 浏览 3 评论 0原文

http://onehackoranother.com/projects/jquery/tipsy/

假设我将鼠标悬停在某物上。工具提示出现在链接上方。当我将鼠标移至工具提示时,它就会消失。有办法保持下去吗?

我问这个问题的原因是因为我想在工具提示内放置一个按钮。我不希望当我点击按钮时它消失。

http://onehackoranother.com/projects/jquery/tipsy/

Let's say I hover over something. And the tooltip appears above the link. When I move my mouse to the tooltip, it disappears. Is there a way to keep it up?

The reason I'm asking this is because I want to put a button inside the tooltip. I don't want it to go away when I go click the button.

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

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

发布评论

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

评论(4

空宴 2024-10-19 23:50:08

请检查以下代码 jquery.tipsy.js 文件

从第 61 行开始

function() {
    $.data(this, 'cancel.tipsy', false);
    var self = this;
    setTimeout(function() {
        if ($.data(this, 'cancel.tipsy')) return;

        var tip = $.data(self, 'active.tipsy');
        if (opts.fade) {
            tip.stop().fadeOut(function() { 
                $(this).remove();   
            });
        } else {
            tip.remove();
        }
}, 100); // <- change 100 to 1000

将指示行上的“100”更改为“1000”。

Please check the following code jquery.tipsy.js file

Starting from line 61 onwards

function() {
    $.data(this, 'cancel.tipsy', false);
    var self = this;
    setTimeout(function() {
        if ($.data(this, 'cancel.tipsy')) return;

        var tip = $.data(self, 'active.tipsy');
        if (opts.fade) {
            tip.stop().fadeOut(function() { 
                $(this).remove();   
            });
        } else {
            tip.remove();
        }
}, 100); // <- change 100 to 1000

Change "100" to "1000" on the indicated line.

嘿哥们儿 2024-10-19 23:50:08

此功能不是内置的,但通过手动显示和隐藏醉酒(使用 trigger: 'manual'$.hover() 来自行添加它并不难)。下面的代码虽然有点长,但应该可以正常工作。

$('.some-class-name').each(function () {

    var me = this,
        timer = null,
        visible = false;

    function leave() {
        // We add a 100 ms timeout to give the user a little time
        // moving the cursor to/from the tipsy object
        timer = setTimeout(function () {
            $(me).tipsy('hide');
            visible = false;
        }, 100);
    }

    function enter() {
        if (visible) {
            clearTimeout(timer);
        } else {
            $(me).tipsy('show');
            // The .tipsy object is destroyed every time it is hidden,
            // so we need to add our listener every time its shown
            $('.tipsy').hover(enter, leave);
            visible = true;
        }
    }

    $(this).tipsy({html: true, trigger: 'manual'});
    $(this).hover(enter, leave);

});

This functionality is not built-in, but it's not so hard to add it yourself by manually showing and hiding tipsy (using trigger: 'manual' and $.hover()). The code below, while a bit lengthy, should work fine.

$('.some-class-name').each(function () {

    var me = this,
        timer = null,
        visible = false;

    function leave() {
        // We add a 100 ms timeout to give the user a little time
        // moving the cursor to/from the tipsy object
        timer = setTimeout(function () {
            $(me).tipsy('hide');
            visible = false;
        }, 100);
    }

    function enter() {
        if (visible) {
            clearTimeout(timer);
        } else {
            $(me).tipsy('show');
            // The .tipsy object is destroyed every time it is hidden,
            // so we need to add our listener every time its shown
            $('.tipsy').hover(enter, leave);
            visible = true;
        }
    }

    $(this).tipsy({html: true, trigger: 'manual'});
    $(this).hover(enter, leave);

});
桃扇骨 2024-10-19 23:50:08

尝试线索提示插件。即下面链接中的粘性选项 -

http://plugins.learningjquery.com/cluetip/demo/< /a>

这个插件很容易使用,并且还有很多配置选项可用。

Try the cluetip plugin. ie sticky option in that from below link -

http://plugins.learningjquery.com/cluetip/demo/

This plugin is easy to use and lot of configuration options are available as well.

饭团 2024-10-19 23:50:08

根据插件文档,您可以在工具提示消失之前设置延迟,请尝试:

$("#element").tipsy({ delayOut: 2000 }); // delay before hiding tooltip (ms)

在此处查看其他配置选项:

http://onehackoranother.com/projects/jquery/tipsy/#options

According to the plug in documentation you can set a delay before the tool tip disappears, try:

$("#element").tipsy({ delayOut: 2000 }); // delay before hiding tooltip (ms)

See other configuration options here:

http://onehackoranother.com/projects/jquery/tipsy/#options

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