Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

check valid tag id

 
reubin haz
Ranch Hand
Posts: 287
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if(typeof(document.getElementById("someId")) != "undefined")alert("I am here");
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic