1<div id="test">Example DIV element.</div>
2
3<script>
4 //Attempt to get the element using document.getElementById
5 var element = document.getElementById("test");
6
7 //If it isn't "undefined" and it isn't "null", then it exists.
8 if(typeof(element) != 'undefined' && element != null){
9 alert('Element exists!');
10 } else{
11 alert('Element does not exist!');
12 }
13</script>
14