Answers for "javascript how to detect button pressed"

6

how to detect a button click in javascript

if(document.getElementById('button').clicked == true)
{
   alert("button was clicked");
}
Posted by: Guest on December-10-2019
0

if button is pressed js

<button>A</button>
<button>B</button>
<button>C</button>
<script>
  document.body.addEventListener("click", event => {
    if (event.target.nodeName == "BUTTON") {
      console.log("Clicked", event.target.textContent);
    }
  });
</script>
Posted by: Guest on March-31-2021

Code answers related to "javascript how to detect button pressed"

Code answers related to "Javascript"

Browse Popular Code Answers by Language