Handling Events in Webscript

Currently reading:
 Handling Events in Webscript

x.MBM

Member
LV
1
Joined
Jul 26, 2023
Threads
10
Likes
1
Awards
4
Credits
979©
Cash
0$
  • Events allow executing code when something happens on a page
  • Common HTML events:
    • click
    • submit
    • change
    • keydown
    • scroll
    • load
  • Adding event listeners:
    element.addEventListener(event, function)
  • Callback functions run when event occurs
  • Accessing event object properties:
    • target
    • type
    • timestamp
    • keyCode etc
  • Examples:
    button.addEventListener('click', function(){ //do something });
    input.addEventListener('keydown', function(event){ if(event.keyCode === 13){ //run code on enter } });
  • Event bubbling/propagation
  • Removing event listeners
  • Differences between HTML and DOM events
  • Listener syntaxes: onclick, addEventListener
  • Tips for efficient event handling
The goal is to explain common events in webscript and show how to attach listeners to react to these events with callback functions.
 

Create an account or login to comment

You must be a member in order to leave a comment

Create account

Create an account on our community. It's easy!

Log in

Already have an account? Log in here.

Tips
Top Bottom