การลงทะเบียน Event Handlers ภายในโค้ด JavaScript ช่วยให้ใช้คีย์เวิร์ด this ได้ ไม่ต้องส่งค่าเข้าไปในฟังก์ชัน ใช้ this เพื่อจัดการ Property แทน
ตัวอย่าง
<!DOCTYPE html> <html>
<head>
<script>
function display() {
click.onclick = styleMe;
uname.onclick = styleMe;
}
function styleMe() {
this.style.backgroundColor = "#000000";
this.style.color = "#FFFFFF";
}
</script>
</head>
<body onload="display()">
<div id="uname"> Hello Wordl!</div>
<button id="click"> Click</button>
</body>
</html>