你好我有一个输入字段很少的表单,一旦用户输入文本字段,我想显示一些与特定字段相关的信息。到目前为止,我设法做到了这一点:
<tr>
<td>Name </td>
<td width="162"><input name="txtname" type="text" id="txtname" /></td>
<td width="333"><span class="style1"><br/>Enter Your Name, Preferably as per your PAN Card</span></td>
</tr>
<tr>
<td>Father Name </td>
<td> <input name="txtfname" type="text" id="txtfname" /></td>
<td><span>Enter Your Father Name Preferably as per your PAN Card</span></td>
</tr>
<tr>
<td>PAN </td>
<td> <input name="txtpan" type="text" id="txtpan" onblur="checkPAN()" maxlength="10" /></td>
<td>Enter Your PAN No. carefully</td>
</tr>
<tr>
<td>Mobile Number </td>
<td> <input name="txtmb" type="text" id="txtmb" maxlength="10" /></td>
<td>Enter your Mobile No. we will be in touch with you with this No In case of any further details</td>
</tr>
<tr>
<td>Confirm Mobile Number </td>
<td> <input name="txtmbcnfrm" type="text" id="txtmbcnfrm" maxlength="10" /></td>
<td>Reenter your Mobile No.</td>
</tr>
<tr>
<td>Email Id </td>
<td> <input name="txtemail" type="text" id="txtemail" onchange="emailval()" /></td>
<td>Enter your Valid email ID to which you need to receive Acknowledgement, </td>
</tr>
应该隐藏文本字段旁边的所有信息,但是当onFocus
应该显示特定信息时,我可以使用jquery
执行此操作,但我很困惑如何到达那里。
答案 0 :(得分:6)
$('input').parent().next().hide();
$('input').on('focus', function () {
$(this).parent().next().show();
});
$('input').on('blur', function () {
$(this).parent().next().hide();
});
这是FIDDLE