Answers for "how to check if an element is still present in javascript"

1

check if an element is there in js

//includes
const fruits = ["apple", "mango", "banana", "kiwi"]
return fruits.includes("mango") ? true : false; //returns true if element is in the array

//find Index
let matchIndex = fruits.findIndex((fruit)=>{return fruit == "mango"});
matchIndex > -1 ? fruits[matchIndex] : null;
//other than -1 means the element is in the array.
Posted by: Guest on July-08-2021
1

check if the element exists in javascript

// HazaaZOOZ - javascript - check if the element exists in javascript

var myEle = document.getElementById("myElement");
    if(myEle){
        var myEleValue= myEle.value;
    }
Posted by: Guest on February-02-2021

Code answers related to "how to check if an element is still present in javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language