JS/jQuery 之change、keypress、input和propertychange


$(function(){
/**
* a、當前對象屬性改變,並且是由鍵盤或鼠標事件激發的(腳本觸發無效)
* b、當前對象失去焦點(onblur)
*/
$("#change").change(function(){
console.log("change="+$(this).val());
});

/**
* a、keypress/keydown/keyup監聽鍵盤事件,鼠標復制黏貼操作無效
*/
$("#keypress").keypress(function(){
console.log("keypress="+$(this).val());
});

/**
* a、input是標准的瀏覽器事件,一般應用於input元素,當input的value發生變化就會發生,無論是鍵盤輸入還是鼠標黏貼的改變都能及時監聽到變化
* b、propertychange,只要當前對象屬性發生改變。
*/

$(".center").delegate(".center_comment" ,"input propertychange " ,function(){
  console.log ($(this).val())
  })

});
</script>
</html>


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM