Important Notice:

Event in JS

Event in JS

18 views 1 min read

JavaScript Event :-

जब Web Page पर कोई action होता है और JavaScript उस action पर response देती है, उसे Event कहते हैं।

या

User या Browser द्वारा किया गया कोई भी action Event कहलाता है।

जब user website पर कुछ करता है जैसे:

  • Button पर click
  • Keyboard से typing
  • Mouse move
  • Form submit

तो JavaScript उस action को पहचानती है और कोई काम करती है।

इसी action को Event कहते हैं।

 

Uses of Event in  JavaScript :-

Events का use website को:

  • Interactive बनाने के लिए
  • User action detect करने के लिए
  • Automatic response देने के लिए

किया जाता है।

Example:-

<!DOCTYPE html>
<html>
<body>
<button onclick="showMessage()">
Click Me
</button>
<script>
function showMessage() {
    alert("Button Clicked");
}
</script>
</body>
</html>

Types of Events

1. Mouse Events

  • click, dblclick, mouseover, mouseout

2. Keyboard Events

  • keydown, keyup, keypress

3. Form Events

  • submit, change, focus, blur

4. Window Events

  • load, resize, scroll

Related Notes