JavaScript element exists

This is a JavaScript Function to check if an element exists, I use it regularly in an If.

The function:

function element_exists (elem) {

The test:

console.log("element exists");
console.log("element not exists");
console.log("element exists");
console.log("element not exists");

Our result:

element exists
element not exists

We could see it works as it should.

4 thoughts on “JavaScript element exists”

  1. Hi to every one, it’s genuinely a nice for me to
    visit this website, it consists of priceless Information.

  2. I enjoy reading a post that can make people think.
    Also, many thanks for allowing me to comment!

  3. Hi I am so glad I found your blog, I really found you by
    accident, while I was looking on Yahoo for something else, Anyhow I am
    here now and would just like to say thanks
    for a marvelous post and a all round entertaining blog (I also
    love the theme/design), I don’t have time to read it all at the moment
    but I have bookmarked it and also included your RSS feeds,
    so when I have time I will be back to read
    more, Please do keep up the excellent jo.

Leave a Reply to CasieGCastile Cancel reply

Your email address will not be published.

20 − eighteen =