By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
426,115 Members | 894 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 426,115 IT Pros & Developers. It's quick & easy.

checking existence of an element?

P: n/a
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.
Jul 20 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
"The Plankmeister" <pl******************@hotmail.com> writes:
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
--
Lasse Reichstein Nielsen - lr*@hotpop.com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.