如何“;重置”;单击事件(使用qtip2)

How to "reset" click event (with qtip2)?

本文关键字:使用 qtip2 事件 单击 重置 如何      更新时间:2023-09-26

我对点击事件和qtip2有点疑问。

在第一次单击元素$j('a[href^="/i/"]')之后,当我再次在它上面移动时,会出现气泡。我希望每次单击元素时都会出现气泡。

我的代码:

$j('a[href^="/i/"]').click(function(event) { 
        event.preventDefault(); 
        $j(this).qtip({
            content: {
                title: {
                    text: title_qtip,
                    button: true,
                },
                text: text_qtip,                
            },
            show: { 
                //  event: false,   <-- doesn't work
                solo: true,
                ready: true 
            },
            hide: false,
        });   
       // $j('a[href^="/i/"]').unbind('click');    <-- doesn't work
       // $j('a[href^="/i/"]').unbind('onmouseover').unbind('onmouseout');   <-- doesn't work
});

首先,不要在事件处理程序中声明qTip2函数。您不希望每次单击对象时都声明一个新的qTip。您所要做的就是更改show函数中的事件行。应该是:

$j(document).ready(function(){
     $j('//selector').qtip({
        content: {
            title: {
                text: title_qtip,
                button: true,
            },
            text: text_qtip,                
        },
        show: { 
            event: 'click',   
            solo: true,
            ready: true 
        },
        hide: false,
    });   
}

点击选择器($j(//your selector))时,这将触发刀具提示。

这是一个更新的小提琴:http://jsfiddle.net/LJwLh/1101/

您的问题似乎是使用了a标记。如果你不想链接到任何东西,就没有理由使用这个标签。