div onclick code example
Example 1: how to add onclick event in javascript
var element = document.getElementById("elem");
element.onclick = function(event) {
console.log(event);
}
Example 2: onclick a tag
<a href='http://www.google.com' onclick='return check()'>check</a>
<script type='text/javascript'>
function check() {
return false;
}
</script>
Example 3: javascript click event
<button onclick="myFunction()">Click me</button>
<p id="demo"></p>
<script>
function myFunction() {
document.getElementById("demo").innerHTML = "Hello World";
}
</script>