I have attached an event to a text box using addEventListener
. It works fine. My problem arose when I wanted to trigger the event programmatically from another
HTML
myLink
JS
// click event listener of the link element --------------
document.getElementById('myLink').addEventListener("click", callLink);
function callLink(e) {
// code to fire
}
// function invoked by the button element ----------------
function fireLink(event) {
document.getElementById('myLink').click(); // script calls the "click" event of the link element
}