如何在jQuery中绑定textarea的change事件? [英] How can I bind to the change event of a textarea in jQuery?
本文介绍了如何在jQuery中绑定textarea的change事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想捕获< textarea>
是否发生任何变化。就像键入任何字符(删除,退格)或鼠标单击并粘贴或剪切一样。是否有可以触发所有这些事件的jQuery事件?
I want to capture if any changes happened to <textarea>
. Like typing any characters (deleting,backspace) or mouse click and paste or cut. Is there a jQuery event that can trigger for all those events?
我尝试过更改事件,但只有在从组件中跳出后才触发回调。
I tried change event, but it triggers the callback only after tabbing out from the component.
使用:如果< textarea>
包含任何文字,我想启用按钮。
Use: I want to enable a button if a <textarea>
contains any text.
推荐答案
实际尝试:
$('#textareaID').bind('input propertychange', function() {
$("#yourBtnID").hide();
if(this.value.length){
$("#yourBtnID").show();
}
});
DEMO
适用于您所做的任何更改,打字,剪切,粘贴。
DEMO
That works for any changes you make, typing, cutting, pasting.
这篇关于如何在jQuery中绑定textarea的change事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文