Answers for "click events javascript"

46

javascript onclick event listener

document.getElementById("myBtn").addEventListener("click", function() {
  alert("Hello World!");
});
Posted by: Guest on July-10-2020
9

javascript click event

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

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

<script>
function myFunction() {
  document.getElementById("demo").innerHTML = "Hello World";
}
</script>
Posted by: Guest on April-10-2020
3

event listener javascript

document.querySelector('div').addEventListener('click', () => {
  console.log('div clicked');
});
Posted by: Guest on October-05-2020
0

does click event work only for buttons

button > * {
  pointer-events: none;
}
Posted by: Guest on December-08-2020

Browse Popular Code Answers by Language