แอตทริบิวต์ HTML ondblclick ถูกทริกเกอร์เมื่อคุณดับเบิลคลิกเมาส์ที่องค์ประกอบ HTML ในเอกสาร HTML
ไวยากรณ์
ต่อไปนี้เป็นไวยากรณ์ -
<tagname ondblclick=”script”></tagname>
ให้เราดูตัวอย่างของ HTML ondblclick event Attribute−
ตัวอย่าง
<!DOCTYPE html>
<html>
<head>
<style>
body {
color: #000;
height: 100vh;
background-color: #FBAB7E;
background-image: linear-gradient(62deg, #FBAB7E 0%, #F7CE68 100%);
text-align: center;
}
.btn {
background: #db133a;
border: none;
height: 2rem;
border-radius: 2px;
width: 40%;
display: block;
color: #fff;
outline: none;
cursor: pointer;
margin: 1rem auto;
}
</style>
</head>
<body>
<h1>HTML ondblclick Event Attribute Demo</h1>
<button class="btn" ondblclick="display()">Double click me</button>
<div class="show"></div>
<script>
function display() {
document.querySelector('.show').innerHTML = 'Hey! you double clicked me';
}
</script>
</body>
</html> ผลลัพธ์

ดับเบิลคลิกที่ปุ่มสีแดงเพื่อทริกเกอร์เหตุการณ์ดับเบิลคลิกที่เมาส์
