If the element is a button, then we will create a template string that contains the button id and innerText. How to know which link was clicked on in JavaScript and PHP DIM is a self-service account management system that allows users to create an Illinois.gov ID and/or reset their Active Directory or Mainframe RACF account password. if clicked anything. But if they click outside of the box element, then we hide it by using the classList.add method to add the .js-is-hidden CSS class (with the display: none property) that we created earlier. addEventListener ("click", => {alert ('hello');}); Example 2: how to check if the button is clicked or not in javascript Back to Travellink Manage my … Expressions, functions, HTTPS, indexof, link, RegEx, JavaScript articles on Yogesh Chauhan's Programming tips and tutorials Blog. javascript get element that triggered event. Do you need help? Use onclick HTML Attribute to Check Button Click in JavaScript.