<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<input type="button" id="target" value="button" />
<script>
var t = document.getElementById('target');
t.onclick = function(event){
var event = event || window.event;
//alert('Hello world, '+event.target.value)
console.dir(event);
var target = event.target || event.srcElement;
alert('Hello world, '+target.value)
}
</script>
</body>
</html>
익스플로워 호환성을 고려하여 문제해결 8이하버전 호환하려면
'HTML 참고서 > HTML 생활코딩 Youtube' 카테고리의 다른 글
22.JavaScript event 2 (0) | 2020.04.17 |
---|---|
20.JavaScript event 1 (0) | 2020.04.17 |
18.JavaScript Inline (0) | 2020.04.17 |
17.JavaScript Coding setInterval (0) | 2020.04.17 |
16.JavaScript NodeText (0) | 2020.04.17 |