Looking for a way to display the name and id of a tag when it is in focus.
For instance,
if focus is on an input with id 1th
, display input
and 1th
using console.log.
if focus is on a textarea with id 2th
, show textarea
and 2th
through console.log.
let ob = window.document.getElementsByTag("");
function getNameAndId(event){
console.log(tag's name and id);
}
ob.addEventListener("focus",getNameAndId);
content:<input id="1th" type="text">
<br/>
content:<textarea id="2th" cols=6 rows=5></textarea>
<br/>
content:<input id="3th" type="text">
<br/>
content:<input id="4th" type="text">
In my example, I am unsure how to define ob
.
let ob = window.document.getElementsByTag("");
Is there a way to display the tag's name and id when it is focused?
console.log(tag's name and id);