jQuery: Check if div with certain class name exists
You can simplify this by checking the first object that is returned from JQuery like so: In this case if there is a truthy value at the first ([0]) index, then assume class exists. Edit 04/10/2013: I’ve created a jsperf test case here.