onchange:当输入框内容发生改变时触发

onresize:窗口大小改变的时候会触发

onscroll:滚动条移动的时候触发

eg:

Video_2020-11-23_190711.wmv (451.5KB)

代码:

  1. <style>
  2. body{
  3. height: 2000px;
  4. }
  5. </style>
  6. <body>
  7. <input type="text" id="input">
  8. <script>
  9. var input = document.getElementById("input");
  10. input.onchange = function(){
  11. console.log("hello world")
  12. }
  13. window.onresize = function(){
  14. console.log(1)
  15. }
  16. window.onscroll = function(){
  17. console.log(2)
  18. }
  19. </script>
  20. </body>