使用js 检测页面元素id=layaContainer 存在时候执行 alertok
以下是使用JavaScript检测页面元素id="layaContainer"存在时执行alert("ok")的示例代码:
if (document.getElementById("layaContainer")) {
alert("ok");
}
该代码首先使用document.getElementById()方法获取id为"layaContainer"的元素,然后使用if语句检查该元素是否存在。如果存在,则执行alert("ok")语句。如果不存在,则不执行任何操作。
原文地址: https://www.cveoy.top/t/topic/eBGM 著作权归作者所有。请勿转载和采集!