Skip to content
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.