Using jQuery tooltip at runtime by livequery

2019-08-31 16:22发布

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条回答
We Are One
2楼-- · 2019-08-31 16:53

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

查看更多
登录 后发表回答