qTip show/hide tooltip on click

我的未来我决定 提交于 2019-12-06 09:23:53

This showMyTT function initializes your tooltips. After running this function for all ids (initialization) you should do something like this:

HTML

<input type="button" value="b1" onClick="toggleQtip('div1');" />

JavaScript

function toggleQtip(id) {
    var div = $('#'+id);
    if (div.data('visible')) {
        div.qtip('hide');
        div.data('visible', false);
    } else {       
        div.qtip('show');
        div.data('visible', true);
    }
}

EDIT

Here's how you can initialize qtip (at least one possibility). Add custom class to all divs you'd like to have a qtip, for example qtiped:

HTML

<div id="div1" class="qtiped">TEST</div>
<input type="button" value="b1" onClick="toggleQtip('div1');" />

and then run the following code:

JavaScript

$(document).ready(function() {
    $('.qtiped').each(function() {
        showMyTT( $(this).attr('id') );
    });
});

Also, inside showMyTT do the following change: show: false in order to avoid autoloading (we want to initialize tooltips, not show them).

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!