Q:

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>
17
<script>
function myFunction() {
  alert("ALERT THIS FUNCTION HAS RUNNED");
}
</script>
<button onclick="myFunction">click to run function</button>
3
document.getElementById("myBtn").addEventListener("click", function() {
  alert("Hello World!");
});
9
document.addEventListener('click', function(e) {
    e = e || window.event;
    var target = e.target || e.srcElement,
        text = target.textContent || target.innerText;   
}, false);
1
document.getElementById('button').onclick = function() {
   alert("button was clicked");
};
2
<button onclick="Function()">Text</button>
7
 document.getElementById("Save").onclick = function ()
    {
     alert("hello");
     //validation code to see State field is mandatory.  
    }
2
<button onclick="myFunction()">Click me</button>

<p id="demo"></p>

<script>
function myFunction() {
  document.getElementById("demo").innerHTML = "Hello World";
}
</script>
9
<a href='http://www.google.com' onclick='return check()'>check</a>

<script type='text/javascript'>
function check() {
    return false;
}
</script>
3
var element = document.getElementById("elem");
element.onclick = function(event) {
  console.log(event);
}
2

<button onclick="myFunction()">Click me</button>
 
0

New to Communities?

Join the community