Skip to content

clairefro/int-u3l6-23-24-student-exercises

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Lesson 3.6: Tech Usage & Events Review

What are Event Handlers? :

  • Event handlers are JavaScript functions that get executed when a specific event occurs. They bring interactivity to web pages.

Common events :

// Click Events
let btn = document.querySelector("button");
btn.addEventListener("click", function() {
  // Code to be executed when the button is clicked.
});

// Key Press Events
document.addEventListener("keypress", function(event) {
  console.log(`Key pressed: ${event.key}`);
});

// Mouse Over Events
let box = document.querySelector(".box");
box.addEventListener("mouseover", function() {
  box.style.backgroundColor = "red";
});

// Form Submission Events
let form = document.querySelector("form");
form.addEventListener("submit", function(event) {
  event.preventDefault(); // Prevents form from submitting traditionally.
  console.log("Form Submitted!");
});

Happy coding! 🚀🌟

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • CSS 38.2%
  • JavaScript 32.7%
  • HTML 29.1%