Get answers to FAQ about hotels, flights, car rental and much more.
how to check if a button is clicked javascript Code Example The JavaScript. No actualy i want to see if it is clicked so i can make furder logics .. so if it is clicked to start th efunction with one parameters,and if not with other. To check if an element was clicked, add a click event listener to the element, e.g. button.addEventListener ('click', function handleClick () {}). The click event is dispatched every time the element is clicked. Here is the HTML for the examples in this article. Copied! And here is the related JavaScript code. Copied! Do you need help? addEventListener ( 'click' , event => { // Check if itâs the list element, we want the clicks only from them if ( event . onclick in every link) would be appreciated You have to put it on each an every link, but if the links don't currently have onclick events, it isn't that big a deal: