[Greasemonkey] Grab text string in TD

Aaron Boodman zboogs at gmail.com
Thu Apr 21 16:45:33 EDT 2005

The easiest way is with the nonStandard, but useful textContent property.


Incidentally, <td> elements don't have an attribute named value, which
is why what you were trying to do did not work. But even if it did,
what you're looking for is not an attribute but the textual content of
the element.

DOM elements don't contain text directly, but text nodes, which in
turn contain the text. So the official way to do what you want would


assuming that the first child is a text node and there are no other
child elements. The whole thing gets pretty messy which is why I
suggest textContent.


On 4/21/05, Dave <relaxedguy at gmail.com> wrote:
> I am figuring out how to remove tables from pages and most of the
> sites I want to do this to are pretty stingy with div's ID's, names,
> etc.
> I am stumped on how to find a <td> cell that contains a particular string.
> I am iterating through a list of <td>'s and attempting to use the
> match function to find which <td> starts with the word "Special".
> I GetElements ByTagName, then for each one:
>  if (td1.getAttribute('value').match(/^Special/))
> ...
> I can't figure out the proper syntax for this. I think that 'value' is
> incorrect but after rtfm'ing for a while I'm still stumped.
> What sites are people using as definitive resources for javascript/DOM
> references in regards to GM?
> My list so far:
> http://kb.mozillazine.org/Parsing_and_serializing_XML
> http://www.howtocreate.co.uk
> http://www.mozilla.org/docs/dom/samples/
> --
> Dave Evans
> _______________________________________________
> Greasemonkey mailing list
> Greasemonkey at mozdev.org
> http://mozdev.org/mailman/listinfo/greasemonkey

More information about the Greasemonkey mailing list