如何取消文本区域或输入的焦点?我找不到$('#my-textarea').unfocus();方法?
当前回答
我喜欢下面的方法,因为它适用于所有情况:
$(':focus').blur();
其他回答
$('#textarea').blur()
文档地址:http://api.jquery.com/blur/
我猜你在找。focusout()
所以你可以这样做
$('#textarea').attr('enable',false)
尝试一下并给出反馈
根据你的问题,我相信答案是如何触发模糊,而不仅仅是(甚至)设置事件:
$('#textArea').trigger('blur');
这对我来说很管用:
// Document click blurer
$(document).on('mousedown', '*:not(input,textarea)', function() {
try {
var $a = $(document.activeElement).prop("disabled", true);
setTimeout(function() {
$a.prop("disabled", false);
});
} catch (ex) {}
});