【问题标题】:Is there a way to change the side/position of a single tooltipster tooltip without having multiple classes?有没有办法在没有多个类的情况下更改单个工具提示工具提示的侧面/位置?
【发布时间】:2020-09-17 04:33:57
【问题描述】:

我目前正在标记解剖图,为了最大限度地减少与图表重叠的标签,我只想设置一些工具提示以从我正在标记的 svg 底部显示。在示例中,我将设置 id 为“mud_levator_mandibulae_externus”的 svg 的工具提示显示在底部而不是顶部。

我知道我可以将每组工具提示分成不同的类,但如果可以的话,我希望将它们全部放在一个类中,因为如果我有不同的类,我的 JavaScript 代码将很繁琐。

我认为您可以在我的工具提示初始化后将特定于 id 的函数添加到标记中,但它不起作用。将其添加到文档就绪功能中也不起作用。

$(document).ready(function() {
            $('.tooltip').tooltipster({
            	theme: ['tooltipster-shadow', 'tooltipster-shadow-customized'],
            	trigger: 'click',
            	});
        });

$('#mud_levator_mandibulae_externus').tooltipster({
	side:'bottom'
});

【问题讨论】:

    标签: javascript html css tooltip tooltipster


    【解决方案1】:

    您可以为您的元素再添加一个 css 类,例如 class="tooltip tooltip-left",然后让您的 functionInit 检测到它并相应地更改 side 选项,例如

    functionInit (instance, helper) {
      if ($(instance.origin).hasClass('tooltip-left')) {
        instance.option('side', 'left')
      }
    }
    

    【讨论】:

      猜你喜欢
      • 2013-02-13
      • 2011-05-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-03-17
      • 2023-04-07
      相关资源
      最近更新 更多