js check if button xists 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: button not exist js
<div id="test">Example DIV element.</div>
<script>
//Attempt to get the element using document.getElementById
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!');
}
</script>