Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Mar 2008
    Posts
    34
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Really quick newb question on .hasAttribute DOM command

    Code:
    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.
    Last edited by brookey86; 04-03-2008 at 08:19 PM.

  • #2
    New Coder
    Join Date
    Mar 2008
    Posts
    34
    Thanks
    6
    Thanked 0 Times in 0 Posts
    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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •