<!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
How can I redirect the user from one page to another using jQuery or pure JavaScript?
Check if a string ends with the given target string
What's the difference between let and var?
How to define Global Variable in JavaScript?
How to set checkbox and radio option checked on load with jQuery?
jQuery move multi select values from one to another multi select list