Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Close all open tipsy tooltip with unique selector

In my project I'm using jquery tipsy tooltp to validate the fields of a form. I would like to hide all open tooltips in one shot without having to specify the id of each element, but unfortunately I can not. I tried this way, but the buttons hide2 and hide3 not work properly.

<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/

How could I do? thank you

like image 934
Paolo Rossi Avatar asked Jan 10 '23 06:01

Paolo Rossi


1 Answers

To hide all the tipsy tooltip just use .tipsy class as a selector and hide it using jquery hide()

CODE :

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

Fiddle Demo

like image 128
kamesh Avatar answered Jan 12 '23 20:01

kamesh