addEventListener:添加事件监听器

element.addEventListener(event, function, useCapture)

event:事件类型,字符串,不要加"on"

function:函数名,也可以就是一个函数(不推荐这么写,这样写无法取消!)

useCapture:默认true,false: 事件在捕获时执行true: 事件在冒泡时执行,stopProgapatation()在两种情况下均有用

IE9以下不支持, 得使用attachEvent()

 

removeEventListerer:移除事件监听器

element.removeEventListener(event, function, useCapture)

IE9以下不支持,得用detachEvent()

使用该方法,三个参数必须与addEventListerer一致

相关文章:

  • 2022-12-23
  • 2021-08-28
  • 2022-12-23
  • 2021-11-30
  • 2021-10-15
  • 2022-12-23
猜你喜欢
  • 2022-01-04
  • 2022-12-23
  • 2021-06-13
  • 2022-12-23
  • 2022-12-23
  • 2021-12-20
  • 2022-12-23
相关资源
相似解决方案