Javascript
이벤트 리스너에서 이벤트 객체 전달 받기.html
Linda~!
2020. 3. 18. 17:54
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<p id="p">마우스를 올려 보세요</p>
<button onclick="f(event)">클릭하세요</button><!--이벤트 리스너-->
<script>
function f(e){
alert(e.type);
}
//p태그에 마우스가 over될 때 f함수 등록
document.getElementById("p").onmouseover = f;
</script>
</body>
</html>