禁用除某些元素之外的jQuery UI工具提示

时间:2014-10-30 22:11:33

标签: javascript jquery jquery-tooltip

我正在寻找正在做的事情的反向here。我想在某些情况下禁用工具提示。

这是我现在使用的代码,只是不确定添加禁用的内容/位置:

$(function() {
$( document ).tooltip({
  position: {
    my: "center bottom-20",
    at: "center top",
    using: function( position, feedback ) {
      $( this ).css( position );
      $( "<div>" )
        .addClass( "arrow" )
        .addClass( feedback.vertical )
        .addClass( feedback.horizontal )
        .appendTo( this );
    }
  }
});

});

1 个答案:

答案 0 :(得分:0)

只需使用特定的选择器而不是document

$(function () {
    $("a.has-tooltip, p").tooltip({
        position: {
            my: "center bottom-20",
            at: "center top",
            using: function (position, feedback) {
                $(this).css(position);
                $("<div>")
                    .addClass("arrow")
                    .addClass(feedback.vertical)
                    .addClass(feedback.horizontal)
                    .appendTo(this);
            }
        }
    });
});

演示:JSFiddle

相关问题