Links

Lists

Latest Updates

Ruby On Rails List
Python list
Advanced Java
The JavaScript List
Apache Users
Full Disclosure
Linux Security

Search the archives!


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Javascript] Check if an element exists in the DOM


  • From: simone at tomato.it (Simone Fumagalli)
  • Subject: [Javascript] Check if an element exists in the DOM
  • Date: Wed Oct 18 07:57:00 2006

Hello.

How do I check if an element with id="XYZ" is present in my page/DOM ?

I've tried with:

if ($('XYZ') == undefined) {
  // Do something
} else {
  // Do something else
}

but, of course, javascript give me an error of undefined object.

Ideas ?

Simone