正确的判断写法如下: if($("#object_id").length>0) { alert('对象存在'); } else { alert('对象不存在'); }