http://learn.jquery.com/using-jquery-core/faq/how-do-i-test-whether-an-element-exists/
if ( $( "#myDiv" ).length ) { $( "#myDiv" ).show(); }
http://www.jb51.net/article/49779.htm
通常我们的做法是
if($('.mydiv').length>0)
比较可靠且不会出错的做法是:
if($('.mydiv').length && $('.mydiv').length>0)
return true;