Using jQuery tooltip at runtime by livequery

邮差的信 提交于 2020-01-06 17:47:28

问题


Does anybody know how to use tooltip at runtime using livequery? I found some infos, but for me it doesnt work.

jQuery('.button').bind('click', function () {
    std();
});

function std () {
    jQuery('.abcd').livequery.run(function() {
        jQuery('.abcd').tooltip();
    });
}

回答1:


I interpret your code to mean this:

When .button is clicked you want to enable the tooltip functionality on all elements with class .abcd. If this is your intention simply use

jQuery('.button').bind('click', function () {
    std(); //activate tooltip support
});

function std () {
    //internal function is called once for every found/new .abcd element
    jQuery('.abcd').livequery(function() {
        $(this).tooltip();
    });
}

Note that probably should prevent .button from being clicked more than once as that could lead to unexpected sideeffects



来源:https://stackoverflow.com/questions/2452645/using-jquery-tooltip-at-runtime-by-livequery

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