我正在尝试在警告框出现后设置一个输入框的焦点。我无法将焦点设置在我的字段上,即ref。
我的代码很简单:
JavaScript
HTML:
编辑:
我的代码很简单:
JavaScript
var toFix = true;
$( "#add" ).click(function(e) {
if(toFix){
if (confirm('Not valid')) $( "#ref" ).focus();
e.preventDefault();
}
});
HTML:
<input class="input-text submit" type="submit" id="add" name="submit" value="Add" style="text-align: center"/>
<input class="input-text" type="text" name="ref" id="ref">
编辑:
注: 演示