<div id="bar" />
<script>
if (document.getElementById('foo') == null) {
alert('foo is missing!');
}
//or:
if ( ! document.getElementById('bar')) {
alert('bar is missing!');
}
</script>
Does an element exist?
Leave a Reply
You must be logged in to post a comment.