View Full Version : Dom object type
Me_Titus
07-02-2007, 05:06 PM
Hi guys,
Just wondering if there is any way on knowing the type of an HTML object.
If I do:
<code>
typeof(document.getElementById(an html table)
</code>
I get object, but not the HTML object type... like table.
Is there any way O can get this??
Many thanks,
MeTitus
Bill Posters
07-02-2007, 05:16 PM
I think that tagName might be what you're after…
e.g.
document.getElementById(an html table).tagName
typeof is used for a different kind of operation.
Me_Titus
07-02-2007, 05:20 PM
I think that tagName might be what you're after…
e.g.
document.getElementById(an html table).tagName
typeof is used for a different kind of operation.
Ok thanks,
MeTitus
Bill Posters
07-03-2007, 11:22 AM
DOM 2+ uses nodeName...
Indeed. Use nodeName.
I knew that one was recommended over t'other by some (e.g. PPK), but got it the wrong way round.
Another important thing for nodeName property. The returned string value is in uppercase (in case of a tag) on using HTML DOM.
Bill Posters
07-03-2007, 12:00 PM
Another important thing for nodeName property. The returned string value is in uppercase (in case of a tag) on using HTML DOM.
+
If you're using the property within an XHTML (as XML mime-type), the string returned will be in lowercase.
To make the reference more portable, it's optimal to use either the toLowerCase() or toUpperCase() method to standardise the casing of the returned string to lowercase or uppercase respectively.
Being an XHTML markup user, I tend to gravitate towards lowercasing.
e.g.
document.getElementById(an html table).nodeName.toLowerCase(); // returns table
I said clearly: HTML DOM (not XML DOM) :-)
Yes, sure, to avoid confusion, if you need to find a certain nodeName, give it always a lowercase
For instance:
if(object.nodeName.toLowerCase()=='table'){
......
}
Bill Posters
07-03-2007, 01:40 PM
I said clearly: HTML DOM (not XML DOM) :-)
Calm down, dear.
I clearly added a plus. It was an addendum, not a correction.
:)
Ok, no offense, I tried to make myself clear, that is all... ;)
What about the other post this user has performed on?:
http://www.codingforums.com/showthread.php?t=117795
Let's help him till the end, but I guess we need to ask him some more things and have some more details. The disabled attribute is a tricky one...
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.