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

    Finding name-and-id-less elements?

    Hi. I am messing around with some GreaseMonkey scripts to clean up some websites that I use a lot, and am having trouble dealing with some of their bad HTML. For example, I would like to address a table cell's properties, but can't for the life of me figure out how to find/address that cell, because it has no name or ID, is inside a row with no name or ID, inside a table with no name or ID, inside a DIV with no name or ID. :/

    There IS an image inside it that has an ID attribute, so I am thinking maybe I can start from their and move 'up' to the parent TD, but I can't figure out how to do that either.

    As a stripped down example, how could I set the (for example) background-color of the TD that contains the anchor and image in this code snip? The image is the only thing with an ID here....

    	<a href="#"><img src="banner.jpg" name="header" id="headerGraphic"></a>
    If this was my page, of course there would be named and ID'd divs and tables and such but I can't control the HTML here...

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Thanked 2,224 Times in 2,211 Posts
    Iterate through the parentNodes until it reaches a node having a nodeName as TD
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)


    Tags for this Thread

    Posting Permissions

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