Programming Tips - jQuery: check if something exists

Date: 2013sep20 Library: jQuery Language: javaScript Q. jQuery: check if something exists A. Use .length like this:
if ($('#mything').length == 0) { // does not exist } else { // is there }
Here we are just checking for one id but it works for any selector. For example to see if the document has any images:
if ($('img').length == 0) { alert('No images'); }