Friday, April 24, 2015

Finding duplicate ids in html nodes

var idList = {};
var nodes = document.getElementsByClassName('');
for (var i in nodes) {
  if (!isNaN(i) && nodes[i].id) {
    idList[nodes[i].id] = idList[nodes[i].id]? idList[nodes[i].id]+1:1;
  }
}
for (var id in idList) {
  if (idList[id] > 1) console.log("Duplicate id: #" + id);
}

No comments:

Post a Comment

Going one step further with Kotlin & gRPC

Recently, I tried using Quarkus with Kotlin for grpc. I have worked with grpc for communication between microservices in Java & Golang. ...