javascript onclick event listener
document.getElementById("myBtn").addEventListener("click", function() {
alert("Hello World!");
});
javascript onclick event listener
document.getElementById("myBtn").addEventListener("click", function() {
alert("Hello World!");
});
how to add onclick event in javascript
var element = document.getElementById("elem");
element.onclick = function(event) {
console.log(event);
}
HTML button onclick
<!DOCTYPE html>
<html>
<head>
<title>Title of the document</title>
</head>
<body>
<p>There is a hidden message for you. Click to see it.</p>
<button onclick="myFunction()">Click me!</button>
<p id="demo"></p>
<script>
function myFunction() {
document.getElementById("demo").innerHTML = "Hello Dear Visitor!</br> We are happy that you've chosen our website to learn programming languages. We're sure you'll become one of the best programmers in your country. Good luck to you!";
}
</script>
</body>
</html>
javascript onclick
document.getElementById("Save").onclick = function ()
{
alert("hello");
//validation code to see State field is mandatory.
}
javascript button onclick
document.getElementById('button').onclick = function() {
alert("button was clicked");
};
javascript onclick
var myElem = document.getElementByID('ElemID');
myElem.onclick = function() {
//do stuff
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us