Skip to main content

jquery match element based on id



I'm a noob to jquery. Stuck and would appreciate some help. Currently building a tool to grab data from a particular page. The page looks like this:







<table width="100%" border="0" align="center" cellpadding="3" cellspacing="1">

<tbody> //This is data group 1

<tr id="parent0"> //Record 1

<td align="left"> <---------- text1 here -------> </td>

<td align="left"> <---------- text2 here -------> </td>

<td align="left"> <---------- text3 here -------> </td>

</tr>

<tr id="parent0"> //Record 2

<td align="left"> <---------- text1 here -------> </td>

<td align="left"> <---------- text2 here -------> </td>

<td align="left"> <---------- text3 here -------> </td>

</tr>

</tbody>

</table>



<table width="100%" border="0" align="center" cellpadding="3" cellspacing="1">

<tbody> //This is data group 2

<tr id="child0"> //Record 1

<td align="left"> <---------- text1 here -------> </td>

<td align="left"> <---------- text2 here -------> </td>

<td align="left"> <---------- text3 here -------> </td>

</tr>

<tr id="child0"> //Record 2

<td align="left"> <---------- text1 here -------> </td>

<td align="left"> <---------- text2 here -------> </td>

<td align="left"> <---------- text3 here -------> </td>

</tr>

</tbody>

</table>







Below is a snippet of the jquery:







ancestor = $(this).closest("tr[id]");



matchedElement = $(this).first();

originalBgColor = $(matchedElement).css('background-color');

$(matchedElement).css('background-color', 'green');

$(matchedElement).bind('click.annotator', function(event) {

event.stopPropagation();

event.preventDefault();

self.port.emit('show',

[

document.location.toString(),

$(ancestor).attr("child0"),

$(matchedElement).text()

]







I'm trying to capture all data from just the <tr> blocks with id parent0, and child0.





In it's current working state, the tool captures all data within the two tables as text. Ideally I'd like to be able to capture all the <TR> blocks separately, put them in an array that I can then iterate over.


Comments

Popular posts from this blog

Slow Android emulator

I have a 2.67 GHz Celeron processor, 1.21 GB of RAM on a x86 Windows XP Professional machine. My understanding is that the Android emulator should start fairly quickly on such a machine, but for me it does not. I have followed all instructions in setting up the IDE, SDKs, JDKs and such and have had some success in staring the emulator quickly but is very particulary. How can I, if possible, fix this problem?