Answers for "js element exists in document"

10

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
0

exist element js

if ($('#element').length) {
	//Checks if element exists
}
Posted by: Guest on February-25-2022

Code answers related to "js element exists in document"

Code answers related to "Javascript"

Browse Popular Code Answers by Language