方法一:判断length是否大于等于1
length大于等于1,则dom节点存在
Object.prototype.exist = function(){
if(typeof this !='undefined' && this.length>=1){
return true;
}
return false;
};方法二:使用document.getElementById方法判断
返回null则dom节点不存在
if (document.getElementById("map")) {
console.log("存在");
console.log(document.getElementById("map"));
} else {
console.log("不存在");
console.log(document.getElementById("map"));
}








