24 09 2020

js

if (document.getElementById("map")) {
        console.log("存在");
        console.log(document.getElementById("map"));
    } else {
        console.log("不存在");
        console.log(document.getElementById("map"));
    }

undefined

undefined

if (!!document.getElementById("map")) {
        console.log("true");
    } else {
        console.log("false");
    }

jquery

if ($("#map").length > 0) {
        console.log("true");
    } else {
        console.log("false");
    }
延伸阅读
  1. ASP.NET MVC QQ互联接入
  2. 修改HTTPS加密协议TLS1.0为TLS1.2
发表评论