how to check if a element exists in javascript code example
Example 1: js check if dom element exists
var myElement = document.getElementById("myElementID");
if(!myElement){
//#myElementID element DOES NOT exist
}
if(myElement){
//#myElementID element DOES exists
}
Example 2: check if the element exists in javascript
var myEle = document.getElementById("myElement");
if(myEle){
var myEleValue= myEle.value;
}