首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
社区首页 >问答首页 >获取名为qTip的元素?

获取名为qTip的元素?
EN

Stack Overflow用户
提问于 2012-05-20 06:01:34
回答 1查看 1.4K关注 0票数 0

我想获取调用qtip弹出窗口的元素。在documentation here中,它允许您设置位置。我想使用像$(this).find('.icon')这样的jquery选择器来设置位置。问题是this不是调用qtip的元素(我认为它是window)。

有人知道如何获得调用它的句柄(就像我将目标设置为false时一样)吗?

谢谢。

在qtip源代码中,我发现了以下内容:if(config.position.target === false) config.position.target = $(this);

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-05-20 16:54:55

这是我想出的解决方案,它似乎起作用了。如果我修改了qtip脚本,可能会有更好的方法,但我不想去管它。

代码语言:javascript
代码运行次数:0
运行
复制
$(".report-error").qtip(
{
    content: 'test content',
    position:
    {
        adjust:
        {
            screen: true
        },
        target: false, //it is changed in the 'beforeRender' part in api section. by leaving it as false here in the qtip it will set it as the position I need using $(this)
        corner:
        {
            target: 'bottomMiddle',
            tooltip: 'topRight'
        }
    },
    show:
    {
        when:
        {
            event: 'click'    
        }
    },
    style:
    { 
        name: 'cream',
        tip:
        {
            corner: 'topRight'
        },
        padding: 0,
        width: 400,
        border:
        {
            radius: 5,
            width: 0
        }
    },
    hide:
    {
        when:
        {
            event: 'unfocus'
        }
    },
    api:
    {
        beforeRender: function() { //get the position that qtip found with $(this) in it's script and change it using that as the start position

            this.options.position.target = $(this.elements.target).find('.icon');
            this.elements.target = this.options.position.target; //update this as well. I don't actually know what it's use is
        }
    }
});

它现在在http://wncba.co.uk/results/的网站上工作

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/10669162

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档