This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes check valid tag id Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "check valid tag id" Watch "check valid tag id" New topic

check valid tag id

reubin haz
Ranch Hand

Joined: May 12, 2005
Posts: 287
I'd like to check if a given tag ID exists or not. I tried
typeof document.getElementById(givenID).innerHTML != "string"
document.getElementById(givenID).innerHTML != null

but both of them fail. Does someone know how to check if the given tag id is valid?


Eric Pascarello

Joined: Nov 08, 2001
Posts: 15376
if(typeof(document.getElementById("someId")) != "undefined")alert("I am here");
I agree. Here's the link:
subject: check valid tag id
Similar Threads
Customize html:label size
how to make a link readonly?
to pass the id into javascript
DOM - remove text question
Jsp code in javascript function