Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create example.js #21

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions example.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//Certainly! Here's a simple example of JavaScript code that will display a message in the console when a button is clicked:
// Get a reference to the button element
const button = document.querySelector('button');

// Add a click event listener to the button
button.addEventListener('click', () => {
// Log a message to the console
console.log('Button clicked!');
});

//This code uses the querySelector method to get a reference to the button element on the page,
//and the addEventListener method to add a click event listener to the button. When the button is clicked,
//the code inside the event listener function will execute, which in this case logs a message to the console using the console.
//log method.