<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Document</title>
<body>
  <form action="">
    <input type="text" name="username">
    <input type="button" >
  </form>
</body>
<script>
  document.getElementById('btn').onclick = function () {
    console.log(Array.prototype.slice.call(arguments)); // [MouseEvent] ie8及以下为空
    console.log(this);  // 该input对象
    console.log(event);  // 该点击事件
    console.log(this.form);  // input所在的表单对象
    console.log(this.form.username.value);  // 用户名input输入的值
  }
</script>
</html>

1、通过此方法绑定的事件,作用域是该元素对象;

2、多次绑定的事件,后面定义的覆盖之前的事件;

3、此方法绑定的事件在事件流中的冒泡过程中触发。

 

相关文章:

  • 2022-01-05
  • 2022-02-09
  • 2021-10-07
  • 2021-11-12
  • 2022-02-25
  • 2022-02-09
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-07
相关资源
相似解决方案