Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

check if an id exists javascript

 var myEle = document.getElementById("myElement");
    if(myEle){
        var myEleValue= myEle.value;
    }

//the return of getElementById is null if an element is not actually 
//present inside the dom, so your if statement will fail, because null 
//is considered a false value
 
PREVIOUS NEXT
Tagged: #check #id #exists #javascript
ADD COMMENT
Topic
Name
4+9 =