参见英文答案 How do you clear the focus in javascript?7个 如何在JQuery中删除TextBox的焦点? 编辑:这是我正在寻找的解决方案: $(this).trigger('blur'); 原因不明,$(this).blur();不工作.我创建了一个新
如何在JQuery中删除TextBox的焦点?
编辑:这是我正在寻找的解决方案:
$(this).trigger('blur');
原因不明,$(this).blur();不工作.我创建了一个新的,清晰的解决方案然后它工作.
JS Fiddle$(function () {
$('input[type=text]').focus(function () {
$(this).val('');
// add the below line to trigger the blur event
$(this).trigger('blur');
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script> <input type="text" value="abcdef">
