Home » Javascript

Display Alert Message on Button Click Event using JavaScript

In this code snippet we will learn how to display an alert message using JavaScript.

JavaScript Code Snippet - 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




Comments and Discussions

Ad: Are you a blogger? Join our Blogging forum.



Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing » Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.