identify the type of an object [ 1145 views ]
Goal: simple way to check the type of a page object
I have found many answers about this question but the useless is much more than the valuable. There is a simple way to identify objects on the page.
For example I have a click listener and I want to know the type of the target object:
$(document).on({
click: function(event){
console.log(event.target, event.target.nodeName);
}
});
No more like this. You can list all of the object types on your page with the following code piece
var all = document.getElementsByTagName("*"), a = [];
for (var item of all) {
var nn = item.nodeName;
!a[nn] && (a[nn] = nn);
}
console.log(a);
console.log(Object.keys(a).toString());
-> HTML,HEAD,META,TITLE,LINK,SCRIPT,BODY,STYLE,DIV,SPAN,IMG,UL,LI,BR,SELECT,OPTION,I,B,A,CANVAS



