<!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
JavaScript calculate Fahrenheit from Celsius
JavaScript HTML5 Validation for name and email field
How can I redirect the user from one page to another using jQuery or pure JavaScript?
How to show hide option list items using jQuery?
How to define Global Variable in JavaScript?
Write a function that splits an array into groups the length of size and returns them as a two-dimensional array