While debugging, I might have an element el
, and I can print it out using console.log(el)
.
There can be 50 or even 100 of them, while debugging. Can I print out something in the debug console in Google Chrome, so that when I click on it, will make the element come into focus in the webpage?
I tried:
let tmpLink = document.createElement("a");
tmpLink.href = "#"; // now it is a link instead of anchor
tmpLink.innerHTML = "Click Me";
tmpLink.addEventListener("click", function() {
el.focus();
});
console.log(tmpLink);
and the link is printed out in the debug console, except when I click on it, doesn't bring me to the element on page. Is there a way to do it?
One less desirable way is to do
window.focusArr = window.focusArr || [];
window.focusArr.push(el);
console.log(`Element ${window.focusArr.length - 1}`);
so I can just do in the console:
focusArr[21].focus()
But is there a way to make clicking on something work in the debug console?