Javascript 仅在单击时打开Jquery ui工具提示

Javascript 仅在单击时打开Jquery ui工具提示,javascript,jquery,ajax,jquery-ui,jquery-ui-tooltip,Javascript,Jquery,Ajax,Jquery Ui,Jquery Ui Tooltip,我有这个密码 function DrawTipsProgress(postid, ajaxurl) { var data = { action: 'ajax_action', post_id: postid } jQuery('#dashicon-' + postid).on("click", function () { jQuery.post(ajaxurl, data, function(response) {

我有这个密码

function DrawTipsProgress(postid, ajaxurl) {

    var data = {
        action: 'ajax_action',
        post_id: postid
    }

    jQuery('#dashicon-' + postid).on("click", function () {

        jQuery.post(ajaxurl, data, function(response) {

            jQuery('#dashicon-' + postid).tooltip({

                position: { my: 'center bottom' , at: 'center top-10' },
                tooltipClass: "myclass",
                content: response

            });

            jQuery('#dashicon-' + postid).tooltip('open');

        });

    });

}
第一次单击时,它将作为aspected工作。
如果稍后我尝试再次悬停按钮而不单击它,则再次弹出工具提示,单击按钮只执行ajax调用,但不打开工具提示

悬停时会触发工具提示。在您的代码中,在“单击”事件发生之前,它不会被绑定到元素,因此它实际上不是导致它显示的单击。。。这是单击后的悬停。我相信你需要做的是使用和使用。这里有一个小提琴的例子。


$('a')。工具提示({
位置:{my:'center-bottom',在:'center-top-10'},
工具类:“myclass”,
残疾人:对,,
关闭:函数(事件,ui){
$(this.tooltip('disable');
/*您还可以使用$(event.target)代替$(this)*/
}
});
$('a')。在('click',函数(){
$(this).tooltip('enable')。tooltip('open');
});

这是一个公认的答案应该是什么样子,并附有解释和工作示例。谢谢。添加ajax,使其完整
<a href="#" title="Anchor description">Anchor text</a>

$('a').tooltip({
    position: { my: 'center bottom' , at: 'center top-10' },
    tooltipClass: "myclass",
    disabled: true,
    close: function( event, ui ) { 
        $(this).tooltip('disable'); 
        /* instead of $(this) you could also use $(event.target) */
    }
});

$('a').on('click', function () {
     $(this).tooltip('enable').tooltip('open');
});