View Full Version : Really quick newb question on .hasAttribute DOM command

04-03-2008, 08:16 PM
for (i=0; i<document.getElementsByTagName("td").length; i++)
if (document.getElementsByTagName("td")[i].hasAttribute("style"))
alert('yes and the position: ' + i);

Why does this .hasAttribute chunk give me a "Object doesn't support this property or method" error? This is supported by DOM, and there are multiple td tags on my page with the style attribute.

testing in IE.

04-03-2008, 09:41 PM
I am getting on the right track. If you were not aware (as I was not), IE does not handle the .hasAttribute() and .getAttribute() tags correctly for "style" and "class". Instead of returning a string, as it should, it returns an object. I am currently working on a fix for this.