首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >当单击元素中的元素时,如何隐藏TippyJS?

当单击元素中的元素时,如何隐藏TippyJS?
EN

Stack Overflow用户
提问于 2021-12-08 10:17:35
回答 1查看 830关注 0票数 4

当一个元素被点击时,我不得不隐藏我的提示(元素是作为链接的小图像),但是我还没有找到任何有用的脚本与我的提示一起工作。

我试过这些都没有运气:

如何在鼠标中心显示工具提示并使用Tippy.js单击隐藏

https://github.com/atomiks/tippyjs/issues/437

有人能帮忙吗?-)

这里是我的TippyJS :

代码语言:javascript
复制
tippy('#ReactionBar' + val, {
  a11y: true,
  role: 'tooltip',
  allowHTML: true,
  animation: 'perspective-extreme',
  appendTo: () => document.body,
  arrow: true,
  arrowType: 'sharp',
  boundary: 'HTMLElement',
  content: ReactionBarContent.get(0).outerHTML,
  delay: 0,
  offset: [0, 5],
  duration: [325, 275],
  hideOnClick: true,
  ignoreAttributes: false,
  inertia: false,
  interactive: true,
  interactiveBorder: 2,
  interactiveDebounce: 0,
  placement: 'top-end',
  popperOptions: {},
  showOnCreate: false,
  size: 'regular',
  target: '',
  theme: 'light',
  touch: true,
  trigger: 'mouseenter focus',
  triggerTarget: null,
  moveTransition: 'transform 0.2s ease-out',
});

EN

回答 1

Stack Overflow用户

发布于 2022-07-18 13:11:09

我也面临着同样的问题,我发现使用onShown支柱和instance.hide()方法是有效的。我发现这不需要hideOnClick道具。

代码语言:javascript
复制
this.tippy = tippy(this.element, {
  // your other props
  interactive: true,
  trigger: 'click',
  triggerTarget: this.triggerTarget,
  onShown(instance) {
    document.querySelector('[data-tippy-root]').addEventListener('click', event => {
      instance.hide();
    })
  }
})
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/70273302

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档