Answers for "dom element exist"

8

js element exists

var element = document.getElementById("test");
    //If it isn't "undefined" and it isn't "null", then it exists.
if(typeof(element) != 'undefined' && element != null){
    alert('Element exists');
} else{
	alert('Element does not exist');
}
Posted by: Guest on February-02-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language