checking existence of an element?

T

The Plankmeister

Is it possible to check for the existence of an element? I have a dynamic
page which may or may not have a <div> holding a bunch of thumbnails, and I
want a function to check for the existence of the <div>. Doing:

blah = getElementById("thumbnails");

Generates an error.... I was hoping it would just return false or
something... Is there a way of doing this?

P.
 
L

Lasse Reichstein Nielsen

The Plankmeister said:
blah = getElementById("thumbnails");
Generates an error....

Probably because it's
var blah = document.getElementById("thumbnails");
^^^^^^^^^
I was hoping it would just return false or something... Is there a
way of doing this?

Using document.getElementById should return "null" if the element
isn't there. Which browser are you using?

/L
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,772
Messages
2,569,593
Members
45,105
Latest member
sheetaldubay7750ync
Top