如何将关闭按钮放在jQuery工具提示 [英] How to put close button at jquery tooltip

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

问题描述

我在我的网页上使用了。



因此,基本上我希望我的代码应该是这样:

  $('。tooltipster-content')。on('click','.close',function(){
$('tooltipster-base')。hide();
} ;

但是,此代码在我的网页上无法正常工作。

解决方案

它不工作的原因是因为您在小提琴中委托的事件不在页面上您绑定的事件。尝试以下操作:

  $(document).on('click','.close',function(){
$('。tooltipster-base')。hide();
});

此外,您缺少点击回调中的 $('。tooltipster-base') jQuery选择器的前面。 p>

DEMO


I've used this tooltip at my webpage. Now, I want to put a "close button" in the tooltip, so if user click on that button, the tooltip will be closed(Though that tooltip close automatically after certain of time but I need to add close button feature too). This is my tooltip:

I need when user click on the close button, the tooltip will be closed.

I put my testing code at jsfiddle.

So, basically I hope, my code should be like this:

$('.tooltipster-content').on('click', '.close', function() {
    $('tooltipster-base').hide();
});

But, this code isn't working at my webpage.

解决方案

The reason it is not working is because the event that you are delegating to in your fiddle is not present on the page when you're binding the event. Try the following:

$(document).on('click', '.close', function() {
    $('.tooltipster-base').hide();
});

In addition, you were missing the . on the front of the $('.tooltipster-base') jQuery selector within your bound click callback.

DEMO

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

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