admin管理员组文章数量:1026373
I'm using tippy.js for tooltips on a website, but it es to a point when I have to hide them manually with a function (on mobile). However I'm unable to hide it using the built in function hide()
Am I doing something wrong or is the library bugged?
Here's the documentation showing the hide() function. And here's a snippet of my problem.
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)
})
button {
margin: 20px;
}
<link href=".css" rel="stylesheet" />
<script src=".js"></script>
<script src=".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>
I'm using tippy.js for tooltips on a website, but it es to a point when I have to hide them manually with a function (on mobile). However I'm unable to hide it using the built in function hide()
Am I doing something wrong or is the library bugged?
Here's the documentation showing the hide() function. And here's a snippet of my problem.
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)
})
button {
margin: 20px;
}
<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./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>
Any and all help appreciated!
Share Improve this question asked Apr 13, 2017 at 7:38 Matthew AbrmanMatthew Abrman 73110 silver badges18 bronze badges1 Answer
Reset to default 3From the documentation:
Find the element's popper reference by calling the method
getPopperElement
and passing in the element directly:
You need to pass your element to getPopperElement
, not the popup.
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)
})
button {
margin: 20px;
}
<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./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>
I'm using tippy.js for tooltips on a website, but it es to a point when I have to hide them manually with a function (on mobile). However I'm unable to hide it using the built in function hide()
Am I doing something wrong or is the library bugged?
Here's the documentation showing the hide() function. And here's a snippet of my problem.
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)
})
button {
margin: 20px;
}
<link href=".css" rel="stylesheet" />
<script src=".js"></script>
<script src=".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>
I'm using tippy.js for tooltips on a website, but it es to a point when I have to hide them manually with a function (on mobile). However I'm unable to hide it using the built in function hide()
Am I doing something wrong or is the library bugged?
Here's the documentation showing the hide() function. And here's a snippet of my problem.
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)
})
button {
margin: 20px;
}
<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./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>
Any and all help appreciated!
Share Improve this question asked Apr 13, 2017 at 7:38 Matthew AbrmanMatthew Abrman 73110 silver badges18 bronze badges1 Answer
Reset to default 3From the documentation:
Find the element's popper reference by calling the method
getPopperElement
and passing in the element directly:
You need to pass your element to getPopperElement
, not the popup.
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)
})
button {
margin: 20px;
}
<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./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>
本文标签: javascriptTippyjsUnable to hide a tooltip using the tippyjs documentation functionStack Overflow
版权声明:本文标题:javascript - Tippy.js - Unable to hide a tooltip using the tippy.js documentation function - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745643517a2160887.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论