Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

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>
Source by eloquentjavascript.net #
 
PREVIOUS NEXT
Tagged: #button #pressed #js
ADD COMMENT
Topic
Name
2+3 =