Answers for "js if exists in page"

3

js check if dom element exists

var myElement = document.getElementById("myElementID");

if(!myElement){
    //#myElementID element DOES NOT exist
}

if(myElement){
    //#myElementID element DOES exists
}
Posted by: Guest on August-05-2019
0

if text exists in element using javascript

if (
  (
    document.documentElement.textContent || document.documentElement.innerText
  ).indexOf('Done successfuly') > -1
) {
  // Do something...
}
Posted by: Guest on October-30-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language