使用jquery或其他库提供表单提示

时间:2010-05-30 08:07:49

标签: javascript jquery mootools scriptaculous

这是jquery的表单验证:

http://www.position-absolute.com/articles/jquery-form-validator-because-form-validation-is-a-mess/

我需要类似的东西,但是当我通过点击选择输入文本表单时必须出现提示,当我选择另一个输入文本表单时必须消失。

有没有办法用jquery,mootools,scriptaculus或任何其他库来做到这一点?

谢谢^ _ ^

1 个答案:

答案 0 :(得分:2)

在jquery中,我会做这样的事情:

$('input').focus(function(){
  $(this).sibling('div.form_tooltip').show();
});
$('input').blur(function(){
  $(this).sibling('div.form_tooltip').hide();
});

对应的html:

<div class="form_input">
  <label for="..">label</label>
  <input type="text" name="" id="" value="" />
  <div class="form_tooltip" style="display: none;">
    Here goes the html that appears in the tooltip, you probably want this div to be positioned relatively to the div.form_input.
  </div>
</div>