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;