मैं एक textarea या इनपुट कैसे निकाल सकते हैं? मुझे कोई $('#my-textarea').unfocus();विधि नहीं मिली ?
मैं एक textarea या इनपुट कैसे निकाल सकते हैं? मुझे कोई $('#my-textarea').unfocus();विधि नहीं मिली ?
जवाबों:
$('#textarea').blur()
प्रलेखन पर: http://api.jquery.com/blur/
$('#textarea').bind('blur', function() ...)यह भी महान काम करता है
आपके प्रश्न के आधार पर, मेरा मानना है कि उत्तर यह है कि कैसे एक धब्बा को ट्रिगर किया जाए , न कि केवल (या यहां तक कि) घटना को सेट करें:
$('#textArea').trigger('blur');
आप के लिए देख रहे हैं लगता है .focusout()
focusoutएक इनपुट के बाद ही निकाल दिया जाता है, जो पहले से ही फोकस खोने लगता है। प्रश्नकर्ता उस स्थिति में एक तत्व डालना चाहता है जो
यह मेरे लिए काम करता है:
// 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) {}
});
तो आप ऐसा कर सकते हैं
$('#textarea').attr('enable',false)
इसे आज़माएं और प्रतिक्रिया दें
.focusout()से थोड़ा अलग है , डॉक्टर को उद्धृत करते हुएblur()This 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)