...

View Full Version : Finding name-and-id-less elements?



KenjiR
03-24-2009, 07:09 PM
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....



<div>
<table>
<tr>
<td>
<a href="#"><img src="banner.jpg" name="header" id="headerGraphic"></a>
</td>




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...

abduraooft
03-24-2009, 07:28 PM
Iterate through the parentNode (https://developer.mozilla.org/En/DOM/Node.parentNode)s until it reaches a node having a nodeName as TD



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum