Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to know object type?

 
ankur rathi
Ranch Hand
Posts: 3830
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We usually get any object in JS like:

document.getElementById('anyId')

How can we know, whcih object it is??

Thanks.

[ June 15, 2006: Message edited by: Bear Bibeault ]
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What do you mean which object? You talking if it is a div or span? Wouldn't you know what it is to begin with?

Eric
[ June 15, 2006: Message edited by: Eric Pascarello ]
 
Manesh Kumar
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is a typeof function in Javascript, but it is not very specific.

If you want what is the element type,

this might help you.


However, I have never found any use of it till now.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic