Answers for "get element on click"

0

javascript click button by id

var button = document.getElementById("button");
button.click();
Posted by: Guest on May-20-2020
0

get element by click

document.addEventListener('click', function(e) {
    e = e || window.event;
    var target = e.target || e.srcElement,
        text = target.textContent || target.innerText;   
}, false);
Posted by: Guest on April-08-2021
0

get element by click

window.onclick = e => {
    console.log(e.target.innerText);
}
Posted by: Guest on April-08-2021
0

get element by click

window.onclick = e => {
    console.log(e.target);  // to get the element
    console.log(e.target.tagName);  // to get the element tag name alone
}
Posted by: Guest on April-08-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language