在我的元素中,我使用 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');
});
我该怎么办?谢谢
最佳答案
要隐藏所有提示工具提示,只需使用 .tipsy 类作为选择器并使用 jquery hide()
代码:
$("#hide2_ttp").click(function(){
$('.tipsy').hide();
});
关于javascript - 使用独特的选择器关闭所有打开的提示工具,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24649120/