javascript - 使用独特的选择器关闭所有打开的提示工具

标签 javascript jquery html css animation

在我的元素中,我使用 jquery tipsy tooltp 来验证表单的字段。 我想一次隐藏所有打开的工具提示,而不必指定每个元素的 id,但不幸的是我不能。 我试过这种方法,但是按钮 hide2 和 hide3 不能正常工作。

<p><input type="text" name="name" id="name" rel="ttp" /></p>
<p><input type="text" name="sname" id="sname" rel="ttp" /></p>
<p><input type="text" name="email" id="email" rel="ttp" /></p>

<input type="button" value="show" id="show_ttp">
<input type="button" value="hide" id="hide_ttp">
<input type="button" value="hide2" id="hide2_ttp">
<input type="button" value="hide3" id="hide3_ttp">

JS

$('[rel=ttp]').tipsy({trigger: 'manual', gravity: 'w'});

$("#show_ttp").click(function(){
   $('#name').attr('title', 'name').tipsy('show');
   $('#sname').attr('title', 'surname').tipsy('show');
   $('#email').attr('title', 'email').tipsy('show');
});

$("#hide_ttp").click(function(){
   $('#name').tipsy('hide');
   $('#sname').tipsy('hide');
   $('#email').tipsy('hide');
});

$("#hide2_ttp").click(function(){
   $('*').tipsy('hide');
});

$("#hide3_ttp").click(function(){
  $('[rel=ttp]').tipsy('hide');
});

http://jsfiddle.net/tm9V2/

我该怎么办?谢谢

最佳答案

要隐藏所有提示工具提示,只需使用 .tipsy 类作为选择器并使用 jquery hide()

隐藏它

代码:

$("#hide2_ttp").click(function(){
    $('.tipsy').hide();
});

Fiddle Demo

关于javascript - 使用独特的选择器关闭所有打开的提示工具,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24649120/

相关文章:

javascript - Facebook javascript 登录 sdk,提要未定义

javascript - 如何通过对象的属性从对象数组中删除特定对象?

javascript - 如何在 iframe 内容变化时获取它的高度?

javascript - 如何在 "numbers"输入字段中设置分钟,它应该只接受0到59的值

javascript - 使用node js和mongodb时出现多个连接错误

javascript - 我如何使用 Twitter Bootstrap 中的弹出框来显示复选框、div block 、 radio 、图像等?

php - 使用 UserFrosting 的 OpenCart 错误重定向

javascript - 如何打印我的单选按钮并在文本区域中输入类型文本?

jquery - 使用 jQuery 将鼠标悬停在鼠标上,鼠标速度太快

html - ios8 Webview svg 嵌入 html 不显示