jQuery工具提示,但单击而不是悬停 [英] jquery tooltip, but on click instead of hover
本文介绍了jQuery工具提示,但单击而不是悬停的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我们使用标题属性在鼠标悬停时显示某些内容。现在,我们希望它在单击时显示。如何获得一个看起来像标题/工具提示的浮动框,但是可以按需显示和隐藏而不是与悬停绑定?
We were using 'title' attributes to display something on mouseover. We want it now to display on a click. How can I get a floating box that looks like a title/tooltip, but can be shown and hidden on demand instead of being tied to a hover?
推荐答案
如果您想对其进行手动编码,则应该可以完成此工作:
If you feel like handcoding it, this should do the job:
html:
<div id="tooltip" style="display:none;">bla bla</div>
<div id="yourLink">Click here to show the tooltip!</div>
和JS:
$('#yourLink').click(function(){
$('#tooltip').toggle();
});
您只需要正确设置工具提示div的样式
You just need to style correctly the tooltip div
那里也有不错的工具提示插件。 iftrue提到了一个,还有这一个
There are also nice tooltip plugins out there. iftrue mentioned one, there is also this one
这篇关于jQuery工具提示,但单击而不是悬停的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文