jQuery to pure Javascript examples – 6
Check if HTML element exists // jQuery if($(“#myElm”).length > 0) { console.log(“Element exists”); } // Pure javascript var my_elm = document.getElementById(“myElm”); if(typeof(my_elm) != ‘undefined’ && my_elm != null){ console.log(“Element exists”); }