html_js - 绑定事件获取event

html_js - 绑定事件获取event

绑定事件获取event

  1. 元素绑定事件参数
<!-- 传入参数event 
  必须是event,e或其他都无法获取PointerEvent
 -->
<div class="player_progress" onclick="clickPlayerProgress(event)"></div>
  1. js 绑定事件参数默认event
<p id="foo">click on this element.</p>
 
<script>
  var p = document.getElementById("foo"); // Find the paragraph element in the page
  p.onclick = showAlert; // Add onclick function to element
    
  function showAlert(event) {
    alert("onclick Event triggered!");
  }
</script>
posted @ 2022-07-26 14:45  zc-lee  阅读(666)  评论(0编辑  收藏  举报