first lets give an ID to your table

<table id="mytable">

now heres your script.

var obj = $("mytable");
var rows = $("tr"):

// according to this we going to find text in the first td of the first tr

rows.each(function(i) {

var columns = rows.eq(i);

alert(columns.eq(0).text());

});

the script above should give you some direction in navigating through a
table and addressing specific columns in specific rows.

but lets say you stuck with only that div having a id and can't do much

then your script would be as follows

var obj = $("#knowndiv");

var navigator = obj.parent();
// you have just set the  navigator to be on the td that wraps the div

navigator = navigator.parent();
// now you selected the td

navigator = navigator.prev();
// you have now selected the previous tr

navigator = $("td", navigator);
// you have now selected the td tag in that tr
// you can alert the text like so

alert(navigator.text();

// however you may be faced with multiple td tags and you only want to alert
the first one
// in that case

navigator = navigator.eq(0);
// you have slected the very first td
alert(navigato.text): On Tue, Jun 2, 2009 at 9:38 PM, con-man-jake <
jakedim...@gmail.com> wrote:

>
> Still a newbie.
> I have this:
>
> <table>
>   <tr>
>
>      <td>
>         text I want to get
>      </td>
>
>      <td>
>      </td>
>
>      <td>
>         <div id="knowndiv"></div>
>      </td>
>
>   <tr>
> </table>
>
> If I have the div with id of "knowndiv" as an object (call it "obj"),
> How do I get the text inside the first <td>?
>

Reply via email to