Lesson 2
~18 min

Events and Interactivity

Make your pages interactive with event handling and user interactions

BEGINNER
Progress0%
1

Adding Click Events

Now let's make things INTERACTIVE! Events are actions that happen on your webpage: - clicks - mouse movements - key presses - form submissions YakaJS makes handling events super easy with the .on() method. Syntax: _('#button').on('click', function() { ... })
Key Points
  • Events make your webpage interactive
  • Use .on() to attach event handlers
  • Common events: 'click', 'mouseover', 'keypress'

Try It Yourself

Practice Exercise

Modify the code below and run it to see the results.

Step 1 of 2