<!DOCTYPE html>
<html>
<body>
<div id="find-me"></div>
<script>
var elementExists = document.getElementById("find-me");
if (typeof(elementExists) != 'undefined' && elementExists != null)
{
alert("find-me id exist");
}
var h5 = document.querySelector('h5');
if (typeof(h5) != 'undefined' && elementExists != null)
{
alert("h5 not exist");
}
</script>
</body>
</html>
Most Helpful This Week
jQuery simple form validations between start date and end date
JavaScript example to change image on click
Highlight and get the details of table row on click using JavaScript
How to declare multiple variables in one statement in Javascript?
How to build simple tabs with jQuery?
Get largest number from each sub-arrays