HTML DOM UiEvent 세부 정보 속성은 계속해서 트리거되는 클릭에 해당하는 숫자를 반환합니다.
참고 − ondblclick 이벤트가 발생하면 반환되는 값은 '2'이고, onmouseover 또는 onmouseout 이벤트가 발생하면 항상 '0'입니다.
구문
다음은 구문입니다 -
지속적으로 트리거된 클릭 수 반환 -
event.detail
이벤트 세부정보의 예를 살펴보겠습니다. 속성 -
예시
<!DOCTYPE html>
<html>
<head>
<title>HTML DOM UiEvent detail</title>
<style>
form {
width:70%;
margin: 0 auto;
text-align: center;
}
* {
padding: 2px;
margin:5px;
}
input[type="button"] {
border-radius: 10px;
}
#playArea {
display: inline-block;
border-radius: 50%;
background-color: #DC3545;
width: 50px;
height: 50px;
border: 3px solid #AC3509;
}
#clickOn {
border: 3px solid #F0FF33;
margin: 15px auto;
border-radius: 50%;
background-color: #FFF933;
width: 10px;
height: 10px;
}
h2 {
display: inline-block;
}
</style>
</head>
<body>
<form>
<fieldset>
<legend>HTML-DOM-UiEvent-detail</legend>
<h2 id="highScore">High Score: 0</h2>
<h2 id="currScore">Current Score: 0</h2><br>
<div id="playArea"><div onclick="getHighScore(event)" id="clickOn"></div></div><br>
</fieldset>
</form>
<script>
var clickOn = document.getElementById("clickOn");
var playDisplay = document.getElementById("playArea");
var highScore = document.getElementById("highScore");
var currScore = document.getElementById("currScore");
var high = 0, score = 0;
function getHighScore(event) {
var score = event.detail;
currScore.textContent = 'Current Score: '+score;
if(score > high){
highScore.textContent = 'High Score: '+score;
high = score;
}
}
</script>
</body>
</html> 출력
노란색 div 요소를 클릭하기 전에 -

노란색 div 요소를 계속 클릭한 후 -

노란색 div 요소를 계속 클릭했지만 이전 시간보다 적은 횟수 -
