jquery input動態綁定onchange事件

<input type=text>綁定onchange事件的注意事項:

$('input[name=myInput]').change(function() { ... });

However, this event will only fire when the selector has lost focus, so you will need to click somewhere else to have this work.

這個事件只有在當輸入框失去焦點時才起作用,你必須通過點擊別的地方來觸發它。


This is so useful, it is worth putting it in an answer. Currently (v1.8*?) there is no .input() convenience fn in jquery, so the way to do it is

$('input.myTextInput').on('input',function(e){
 alert('Changed!')
});
這個纔是常用 的,jquery挖了個坑


$('elementName').keyup(function() {
 alert("Key up detected");
});
這個方法也可以用


http://stackoverflow.com/questions/1443292/how-to-implement-onchange-of-input-type-text-with-jquery


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章