get element on click with button js code example
Example 1: get element by click
window.onclick = e => {
console.log(e.target.innerText);
}
Example 2: 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);