Check if element exist in JavaScript or not
- سُلَيْمَان بْن دَاوُوْد

- Jun 5, 2020
- 1 min read
This would prevent unnecessary error on other pages of focus element not found.
var elementExists = document.getElementById("closepopbtn"); if(elementExists){ document.getElementById('closepopbtn').onclick = function() { document.getElementById('popup').style.display = 'none' }; }
Comments