if ($("#elementId").length > 0){ // do something here}//该片段来自于http://www.codesnippet.cn/detail/151020136419.html
来源: http://www.codesnippet.cn/detail/151020136419.html