jquery - 工具提示关闭按钮

标签 jquery button tooltip hide tooltipster

我正在使用tooltipster ,并有一个工具提示,显示何时单击菜单按钮(该位工作正常)。 不过,我在使用工具提示内的关闭按钮关闭工具提示时遇到问题。

我一定错过了一些非常简单的东西。

HTML

<span class="tooltip-email-share"> Stuff </span>

<!-- is triggered by this link -->
<ul>
 <...>
 <li><a class="menu-share"></a></li>
 <...>
</ul>

工具提示的 HTML(以防万一)

<div class="tt-email-share">
    <span class="tt-close"></span>
    <h1>Title</h1>
    <form>
    </form>
</div>

JS

// initiates the tooltip - trigger set to custom & autoClose is false, so it wont close without pressing the close button.

$('.tooltip-email-share').tooltipster({
    theme: 'tooltipster-html-shadow',
        interactive: 'true',
        autoClose: 'false',
        position: 'bottom',
        speed: '200',
        trigger: 'custom',
    content: $('HTML Stuff in here')
    });

// Shows the tooltip (this bit works a charm)

    $('.menu-share').click(function(){
        $('.tooltip-email-share').tooltipster('show');    
    }); 

// *should* close the tooltip (doesn't work)

    $('.tt-close').click(function(){
        $('.tooltip-email-share').tooltipster('hide');
    }); 

最佳答案

解决方案是(感谢一位同事帮助我解决这个问题):

关闭按钮在我定位的时间点并不存在。因此,我必须添加一个 functionReady 函数,以便在加载工具提示后运行单击脚本。

完美运作。

$('.tooltip-email-share').tooltipster({
    theme: 'tooltipster-html-shadow',
    interactive: 'true',
    autoClose: 'false',
    position: 'bottom',
    speed: '200',
    trigger: 'custom',
    content: $('HTML stuff in here'),
// new function here 
    functionReady: function(){ 
        $('.tt-close').click(function(){
            $('.tooltip-email-share').tooltipster('hide');
        });
    }
});

关于jquery - 工具提示关闭按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25983192/

相关文章:

javascript - 使用按钮发布到 php 脚本

WPF- 将工具提示背景更改为透明

java - 与 弹出框架相关

检查 div 中的字符长度时,JQuery '.length' 属性返回不正确的值

jQuery:如何制作一个清晰的按钮?

javascript - 将 jQuery 事件处理程序添加到具有通配符 ID 的元素

javascript - 检查是否单击了按钮...不起作用

grid - 在 wx.grid wxpython 中用鼠标悬停在单元格上时的工具提示消息

使用 div 和分页的 Jquery Slider

javascript - jQuery on future 媒体元素的功能