How to detect missing IDs/classes?

How to detect missing IDs/classes?

Hello,

I've been thrown a site to fix that has lots of unneeded jquery, e.g. $('#ThisIDDoesn'tExist').DoSomething();  JQuery silently passes over these invalid statements, but I'd like to be able to figure out a way to catch these across the whole site, and clean these up.

Any ideas on how I can easily see across the whole site, when a jquery selector returns nothing?

Thanks,
Michael