2019-05-27 事件对象
2019-05-27 本文已影响0人
qiaoguoxing
像这个样子不知道到底怎么拿到参数的时候可以通过console.log()的方式把event打印出来
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<!-- <button id="aaa" style="width:80px; height:20px;"></button> -->
<input style="width:80px;height:20px" id="aaa" type="button" type="button" value="qs">
</body>
<script>
var aaa = document.getElementById('aaa');
aaa.onclick = function(event){
console.log(event.target.offsetHeight);
console.log(event.target.offsetWidth);
}
</script>
</html>