我正在验证表单输入,例如单击按钮时说名字。如果为空,我将类更改为
.ValidateError
{
border: 3px solid #ff9600;
background: #ffebe9;
padding: 4px 4px 5px 4px;
color: #404040;
}
专注于文本框,我尝试使用 document.ready
上的以下脚本从输入框中删除此类
$('#divPersonalInfo input').focusin(function () {
$(this).removeClass().addClass('input w220');
});
});
这是html代码
<div id="divPersonalInfo" class="PersonalInfo">
<h2 id="hPersonal">
Personal Information
</h2>
<div class="FormColumn FloatLeft">
<label>
first name*
</label>
<br />
<input maxlength="100" id="txtFirstName" placeholder="First Name" class="input w220 "/>
</div>
<div class="FormColumn FloatLeft">
<label>
last name*
</label>
<br />
<input maxlength="100" id="txtLastName" placeholder="Last Name" class="input w220"/>
</div>
<div class="FormColumn FloatLeft">
<label>
email*
</label>
<br />
<input maxlength="100" id="txtPersonalEmailId" placeholder="will be seen when sending your web profile/app to your colleagues" class="input w220"/>
</div>
</div>
但是该类并未在焦点上被删除
最佳答案
如果你只想删除“ValidateError”,你应该写一个类名
$(this).removeClass("ValidateError");
顺便说一句。使用 jquery 你可以像这样使用你的焦点
$(selector).focus(function)
关于javascript - jquery focusin 事件未触发,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18206886/