首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Tippy.js -无法使用tippy.js文档函数隐藏工具提示

Tippy.js -无法使用tippy.js文档函数隐藏工具提示
EN

Stack Overflow用户
提问于 2017-04-13 07:38:20
回答 1查看 6.7K关注 0票数 1

我在网站上使用tippy.js作为工具提示,但到了一定程度时,我必须用一个函数(在移动上)手动隐藏它们。但是,我无法使用内置函数hide()隐藏它

我是做错什么了还是图书馆被窃听了?

下面是显示hide()函数的文档。这是我问题的一个片段。

代码语言:javascript
复制
var instance = new Tippy('button')

var i = 0;

$(document).on('keyup', function() {
  $('.clickcount').html(i);
  i++;

  var popper = instance.getPopperElement(document.querySelector('.tippy-popper'));
  instance.hide(popper)

})
代码语言:javascript
复制
button {
  margin: 20px;
}
代码语言:javascript
复制
<link href="https://atomiks.github.io/tippyjs/tippy/tippy.css" rel="stylesheet" />
<script src="https://atomiks.github.io/tippyjs/tippy/tippy.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>



<button title="text">Button with Tippy</button>

<div class="clickcount">Focus the document, then hover the button and press any key to hide it.</div>

任何和所有的帮助感谢!

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-04-13 08:09:52

来自文档

通过调用getPopperElement方法并直接传入元素,查找元素的popper引用:

您需要将元素传递给getPopperElement,而不是弹出窗口。

代码语言:javascript
复制
var instance = new Tippy('button')

var i = 0;

$(document).on('keyup', function() {
  $('.clickcount').html(i);
  i++;

  var popper = instance.getPopperElement(document.querySelector('button'));
  instance.hide(popper)

})
代码语言:javascript
复制
button {
  margin: 20px;
}
代码语言:javascript
复制
<link href="https://atomiks.github.io/tippyjs/tippy/tippy.css" rel="stylesheet" />
<script src="https://atomiks.github.io/tippyjs/tippy/tippy.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>



<button title="text">Button with Tippy</button>

<div class="clickcount">Focus the document, then hover the button and press any key to hide it.</div>

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/43386269

复制
相关文章

相似问题

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