如何在JQuery中删除TextBox的焦点?
编辑:这是我正在寻找的解决方案:
$(this).trigger('blur');
Run Code Online (Sandbox Code Playgroud)
原因不明,$(this).blur();没有用.我创建了一个新的,清晰的解决方案然后它工作.
$(function () {
$('input[type=text]').focus(function () {
$(this).val('');
// add the below line to trigger the blur event
$(this).trigger('blur');
});
});Run Code Online (Sandbox Code Playgroud)
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<input type="text" value="abcdef"> Run Code Online (Sandbox Code Playgroud)