JQuery to check for duplicate ids in a DOM -


I am writing an application with ASP.NET MVC. Unlike traditional ASP.NET, you have all the pages in your generated page More responsible for creating the ID. ASP.net will give you dirty but unique ID.

I want to add a quick short jQuery script to check my document for duplicate IDs. They can have ID for DIVs, pictures, checkboxes, buttons etc.

  & lt; Div id = "pnlmain" & gt; My main panel & lt; / Div & gt; & Lt; Div id = "pnlMain" & gt; Oh, we accidentally used the same ID & lt; / Div & gt;  

I am looking for a set and can forget the typed utility which only warns me when I do some carelessness.

Yes, I use it only during testing, and the options (such as Firebug plugins) are also welcome.

A warning will log for the following consoles:

  / each Warning duplicate ID $ ('[id]'). Each (function () {var ids = $ ('[id = "' this.id + '"]'); if (idE.lamp & gt; 1 & amp; amp;;; ids [0] == this) Console.warn ('multiple id #' + this.id);});  

Comments