Display Alert Message On Button Click Event Using JavaScript

Home » JavaScript Examples

Display Alert Message on Button Click Event using JavaScript

In this code, we will learn how to display an alert message using JavaScript?

Display Alert Message on Button Click Event

HTML and JavaScript:

<!--Display Alert Message on Button Click Event.--> <html> <head> <title>Display Alert Message on Button Click Event.</title> <script type="text/javascript"> function showMessage() { alert("Hello friends, this is message."); } </script> </head> <body> <center> <h1>Display Alert Message on Button 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:

display alert message on button click event Click for DEMO →

JavaScript Examples »

Display different Alert Message on different Button Click Event using JavaScript JavaScript - Print value of all checked (selected) CheckBoxes on Button click

Related Examples

  • JavaScript - Redirect to another URL on Button Click
  • JavaScript - Display Input Text into Lowercase
  • JavaScript - Display Input Text into Uppercase
  • JavaScript - Display current Date and Time
  • Check selected Radio Button value using JavaScript
  • JavaScript function to add two integer numbers
  • Show/Hide Div on Button Click using JavaScript
  • Display different Alert Message on different Button Click Event using JavaScript
  • JavaScript - Print value of all checked (selected) CheckBoxes on Button click
  • JavaScript - Print Selected Item from SelectBox
  • JavaScript - Add user entered item into ListBox
  • JavaScript - Required Field Validator for TextBox on Submit
  • JavaScript - Move Object with Arrow Keys using JavaScript Function
  • JavaScript - Set Focus on Particular Field in a Form using JavaScript Function
  • JavaScript - Set Customize Text in Browser Status Bar using JavaScript Function
  • JavaScript | Create an object by passing values in the function and display in the table
  • JavaScript - Detect and Display Screen Resolution using JavaScript Function
  • JavaScript - Function to Refresh Page on Button Click
  • JavaScript - Function to Display Table of an entered Number
  • JavaScript - Disable Button after Click using JavaScript Function
  • JavaScript - Close Current Tab on Button Click with Confirmation
  • JavaScript - Show/Hide Paragraph Text inside Div on Button Click
  • Simple Web Dictionary | JavaScript Switch Statement Project
  • Data Unit Conversion Tool in JavaScript
  • Age calculator Web Application | Integrating JavaScript function with form
  • Lowercase to Uppercase Converter JavaScript Tool | Web App Project
  • Sample report card web application prototype using JavaScript
  • JavaScript | Create an object and display its values in a table
  • JavaScript | Create an object and display its content in a table through JavaScript function
Advertisement Advertisement

Comments and Discussions!

Load comments ↻

Từ khóa » Html Js Alert Button