Alternatively, you can opt to not load an entire Javascript library for something as simple as this:

document.querySelector('#button').addEventListener('onclick', exit_alert);
Answer from anon on Stack Overflow
🌐
W3Schools
w3schools.com › js › tryit.asp
W3Schools Tryit Editor - JavaScript Alert
The W3Schools online code editor allows you to edit code and view the result in your browser
🌐
Codecademy
codecademy.com › forum_questions › 512d28a06918338f2300e9ea
How to make a html button clickable and to show alert on it ? | Codecademy
Do you mean for the button to pop up an alert when clicked or for the button to have “alert” written on it? Here’s both: <script> function clickAlert() { alert("Alert!"); } </script> <input type="button" onclick="clickAlert()" ...
🌐
IncludeHelp
includehelp.com › code-snippets › display-alert-message-on-button-click-event.aspx
Display Alert Message on Button Click Event using JavaScript
HTML and JavaScript: <!--Display ... Click Event.</h1> <b>Click on button to display message: </b><br /> <br /> <input type="button" id="btnShowMsg" value="Click Me!" onClick="showMessage()" /> </center> </body> </html> Result: Click for DEMO → ·...
🌐
TutorialsPoint
tutorialspoint.com › javascript-create-an-alert-on-clicking-an-html-button
JavaScript - Create an alert on clicking an HTML button
March 11, 2025 - <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> </head> <link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css"> <script src="https://code.jquery.com/jquery-1.12.4.js"></script> <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script> <body> <button type="button">Please Press Me</button> </body> <script> var pressedButton = document.getElementsByTagName("button")[0]; pressedButton.addEventListener("click", function (event) { alert("You have pressed the button..........") }) </script> </html> ... Whenever you press the button, you will get an alert message. ... In this article, we learned how to create an alert message when clicking an HTML button using JavaScript.
🌐
W3Schools
w3schools.com › howto › howto_js_alert.asp
How To Create an Alert Message Box
If you want the ability to close the alert message, add a <span> element with an onclick attribute that says "when you click on me, hide my parent element" - which is the container <div> (class="alert"). Tip: Use the HTML entity "&times;" to ...
🌐
University of Washington
washington.edu › accesscomputing › webd2 › student › unit5 › module2 › lesson1.html
Lesson 1: Using JavaScript to Show an Alert
The button includes the onclick attribute, which causes the showAlert() to be called when a user clicks the button. The onclick event also works for keyboard users. If a user navigates to the button using the tab key, then presses enter, that too will trigger the alert.
🌐
CodePel
codepel.com › home › html & css › alert message in html on button click
Alert Message in HTML on Button Click — CodePel
January 27, 2024 - Here is a free Alert Message in HTML on Button Click , source code with preview. You can view demo online & download code.
Address   Rafi Qamar Road, Al-Majeed Peradise Al Majeed Peradise, 62300, Bahawalpur
Find elsewhere
🌐
SheCodes
shecodes.io › athena › 40000-how-to-create-a-button-with-click-alert-in-javascript
[JavaScript] - How to create a button with click alert in | SheCodes
Learn how to create a button in HTML and add a click event listener in JavaScript to show an alert message ... if I have a variable outside a function, do I need to redefine that variable inside the function? similarly, can use the same name for a variable if one is in a function?
🌐
Indiana
info.sice.indiana.edu › ~hrosenba › Demo › javascript › 6alert.html
Alert and Confirm
This is how the script would look: It is important to note the placement of quotation marks in these examples. In the examples where the code is triggered by a button click, the entire code must by contained in quotation marks: onClick="alert( 'Your Message Here...'
🌐
Stack Overflow
stackoverflow.com › questions › 66790588 › alert-message-on-button-submit-javascript
html - alert message on button submit javascript - Stack Overflow
Works fine, but it doesn't refresh ... this is a decent starting point: function myFunction() { alert("message successfully sent").then(response => { window.location.href = 'index.html'; }) }...
🌐
EDUCBA
educba.com › home › software development › software development tutorials › javascript tutorial › javascript onclick alert
JavaScript onclick Alert | How does JavaScript onclick Alert work?
October 18, 2022 - We have created the onclick() function and alert() function on same program the html tag elements like button etc will used to create and designed for html web pages and it will call the JavaScript functions for authentication or validation purpose.
Address   Unit no. 202, Jay Antariksh Bldg, Makwana Road, Marol, Andheri (East),, 400059, Mumbai
🌐
GeeksforGeeks
geeksforgeeks.org › how-to-set-alert-message-on-button-click-in-jquery
How to set alert message on button click in jQuery ? | GeeksforGeeks
September 23, 2024 - Setting an alert message on a button click in jQuery means using jQuery to capture the button's click event and trigger a browser alert box.
🌐
GeeksforGeeks
geeksforgeeks.org › html › html-dom-window-alert-method
HTML DOM Window alert() Method - GeeksforGeeks
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Alert Hostname Example</title> </head> <body style="text-align: center;"> <h1 style="color: green;"> Geeks </h1> <p> To see the hostname of the current URL, click the "Show Hostname" button: </p> <button onclick="showHostname()"> Show Hostname </button> <script> function showHostname() { let currentURL = window.location.hostname; alert("The hostname of the current URL is: " + currentURL); } </script> </body> </html>
Published   1 week ago
🌐
Codeconvey
codeconvey.com › home › display message on button click in html
Display Message on Button Click in HTML | Codeconvey
August 28, 2023 - In this tutorial, you will learn how to display a message box on button click in HTML, CSS & JS. You can also download code for messgae box.
🌐
W3Schools
w3schools.com › howto › howto_css_alert_buttons.asp
How To Create Alert Buttons
Well organized and easy to understand Web building tutorials with lots of examples of how to use HTML, CSS, JavaScript, SQL, Python, PHP, Bootstrap, Java, XML and more.
🌐
W3Schools
w3schools.com › js › js_popup.asp
JavaScript Popup Boxes
The window.alert() method can be written without the window prefix. ... A confirm box is often used if you want the user to verify or accept something. When a confirm box pops up, the user will have to click either "OK" or "Cancel" to proceed.
🌐
Bootstrap
getbootstrap.com › docs › 4.0 › components › alerts
Alerts · Bootstrap
Provide contextual feedback messages for typical user actions with the handful of available and flexible alert messages. Alerts are available for any length of text, as well as an optional dismiss button. For proper styling, use one of the eight required contextual classes (e.g., .alert-success).