checking existence of an element?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • The Plankmeister

    checking existence of an element?

    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.


  • Lasse Reichstein Nielsen

    #2
    Re: checking existence of an element?

    "The Plankmeister" <plankmeister_N OSPAM_@hotmail. com> writes:
    [color=blue]
    > blah = getElementById( "thumbnails ");[/color]
    [color=blue]
    > Generates an error....[/color]

    Probably because it's
    var blah = document.getEle mentById("thumb nails");
    ^^^^^^^^^
    [color=blue]
    > I was hoping it would just return false or something... Is there a
    > way of doing this?[/color]

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

    /L
    --
    Lasse Reichstein Nielsen - lrn@hotpop.com
    Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit. html>
    'Faith without judgement merely degrades the spirit divine.'

    Comment

    Working...