To handle an event using JavaScript, use click, for mouse click event on any element.
You can try to run the following code to learn how to handle bind an event using JavaScript:
<!DOCTYPE html> <html> <body> <a href="#" id="anchor">Click me</a> <script> document.getElementById('anchor').addEventListener('click', function() { alert('You have clicked the link'); }); </script> </body> </html>