Search code examples
jqueryparsingjavascript-injection

Traversing tables? (FF 4)


I'm trying to parse http://www.MMORPG.com/gamelist.cfm using injected JQuery, and it works fine down to the table level, using $("#gamelisttable > tbody > tr"), but if I try, say, iterating over it:

var games = $("gamelisttable > tbody > tr");
for(var i = 0; i < games.length; ++i)
    games[i].children().css("font-weight", "bold");

I get errors like games[i].children is not a function). The type of games[i] is showing as [object XrayWrapper [object HTMLTableRowElement]]. How do I traverse deeper than this, and why isn't it working?

My actual goal is to, for each row, compare data in that row to a list of criteria, and if they match, find the second cell element, take the link in that cell element, and bold the link text. Perhaps there's a better way to be doing it.


Solution

  • with games[i] your are accessing the element at position i in the jQuery list, which will return the plain HTML-object. Try wrapping it with the $-function.

    $(games[i]).children().css(...)