<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