How can I unfocus a textarea or input? I couldn't find a $('#my-textarea').unfocus();
method?
This question is related to
javascript
jquery
Guess you are looking for .focusout()
Based on your question, I believe the answer is how to trigger a blur, not just (or even) set the event:
$('#textArea').trigger('blur');
This works for me:
// 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) {}
});
I like the following approach as it works for all situations:
$(':focus').blur();
So you can do this
$('#textarea').attr('enable',false)
try it and give feedback
Source: Stackoverflow.com