Làm thế nào tôi có thể không tập trung vào một textarea hoặc đầu vào? Tôi không thể tìm thấy một $('#my-textarea').unfocus();phương pháp?
Làm thế nào tôi có thể không tập trung vào một textarea hoặc đầu vào? Tôi không thể tìm thấy một $('#my-textarea').unfocus();phương pháp?
Câu trả lời:
$('#textarea').blur()Tài liệu tại: http://api.jquery.com/blur/
$('#textarea').bind('blur', function() ...)cũng
                    Dựa trên câu hỏi của bạn, tôi tin rằng câu trả lời là làm thế nào để kích hoạt một vệt mờ , không chỉ (hoặc thậm chí) đặt sự kiện:
 $('#textArea').trigger('blur');Đoán bạn đang tìm kiếm .focusout()
focusoutđược kích hoạt sau khi đầu vào đã bắt đầu mất tập trung. Người hỏi muốn đặt một phần tử ở trạng thái đó, trình xử lý cuộc gọi lại sẽ giúp anh ta không có nhà phát triển  tốt.mozilla.org / en
                    Điều này làm việc cho tôi:
// 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) {}
});
.focusout()hơi khác so vớiblur()api.jquery.com/f Focusout , trích dẫn tài liệuThis is distinct from the blur event in that it supports detecting the loss of focus on descendant elements (in other words, it supports event bubbling)