xxxxxxxxxx
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<button onclick="myFunction()">Click me</button>
<script>
function myFunction() {
alert("Button clicked!");
// Perform additional actions here
}
</script>
</body>
</html>
xxxxxxxxxx
<!DOCTYPE html>
<html>
<body>
<h2>GeeksforGeeks</h2>
<h3>onClick Event Attribute</h3>
<span>Click the button to see the date & time.</span>
<button onclick="getElementById('time').innerHTML= Date()">
Show Date
</button>
<p id="time"></p>
</body>
</html>
xxxxxxxxxx
<script>
function myfunc() {
alert("hi!")
}
</script>
<button onclick="myfunc()">alert me</button>