run a function when a button has the onclick
<script>
function myFunction() {
alert("ALERT THIS FUNCTION HAS RUNNED");
}
</script>
<button onclick="myFunction">click to run function</button>
run a function when a button has the onclick
<script>
function myFunction() {
alert("ALERT THIS FUNCTION HAS RUNNED");
}
</script>
<button onclick="myFunction">click to run function</button>
javascript button onclick
document.getElementById('button').onclick = function() {
alert("button was clicked");
};
onclick="to Function()
<button onclick="topFunction()" id="myBtn" title="Go to top">Top</button>
<script>
//Get the button
var mybutton = document.getElementById("myBtn");
// When the user scrolls down 20px from the top of the document, show the button
window.onscroll = function() {scrollFunction()};
function scrollFunction() {
if (document.body.scrollTop > 20 || document.documentElement.scrollTop > 20) {
mybutton.style.display = "block";
} else {
mybutton.style.display = "none";
}
}
// When the user clicks on the button, scroll to the top of the document
function topFunction() {
document.body.scrollTop = 0;
document.documentElement.scrollTop = 0;
}
</script>
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