File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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 Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "check valid tag id" Watch "check valid tag id" New topic
Author

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"
or
document.getElementById(givenID).innerHTML != null

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

thanks.


SCJA, SCJP5.0, SCBCD, SCWCD
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
if(typeof(document.getElementById("someId")) != "undefined")alert("I am here");
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: check valid tag id