如何在点击时显示工具提示 [英] How to show tooltip on click

查看:69
本文介绍了如何在点击时显示工具提示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 qtip2 。我的问题是,我只想在用户点击带有指定html的 href 时显示工具提示。所以我试试这个:

I'm trying to use qtip2. My problem is that I want to show tooltip only when user clicks an href with a specified html inside. So I try this:

function help(){
    var link = document.getElementById('helps');
    if(link.innerHTML=="Open"){
        $('#helps').qtip({
           content: {
              text: 'I get shown on click'
           },
           show: {
              event: 'click'
           }
        });
    link.innerHTML = "Close";
    }else{
        link.innerHTML="Open";
    }
}
<a href="javascript:help()" id="helps">Open</a>

我的问题是当我点击时,文字变为关闭但工具提示没有显示。当我再次点击时,文字变为打开,我看到工具提示。我该怎么办?

My problem is that when I click, text becomes Close but tooltip doesn't show. When I click again text becomes Open and I see tooltip. What can I do?

推荐答案

我认为你可以使用:

$('#helps')。qtip({
content:{
text:'我点击'
}时显示};

$('#helps').qtip({ content: { text: 'I get shown on click' });

是获得经典工具提示的最佳方式..

is the best way to have classic tooltip..

这篇关于如何在点击时显示工具提示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆