检查一个div是否不存在与JavaScript [英] Check if a div does NOT exist with javascript

查看:67
本文介绍了检查一个div是否不存在与JavaScript的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  if(document.getif(document.getElementById('if')) {

}

但是,如何检查给定的div id不存在?

解决方案

  var myElem = document.getElementById('myElementId') ; 
if(myElem === null)alert('does not exist!');


Checking if a div exists is fairly simple

if(document.getif(document.getElementById('if')){

}

But how can I check if a div with the given id does not exist?

解决方案

var myElem = document.getElementById('myElementId');
if (myElem === null) alert('does not exist!');

这篇关于检查一个div是否不存在与JavaScript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆