jquery mobile referencing a TR table element

Hi there,
I have the following code:

alert($(this).parent().parent().html());

It shows the contents of a row from a table like this :

                    <td>
                        ONE
                    </td>
                    <td>
                        TWO
                    </td>            
                    <td>
                        THREE
                    </td>

I need to be able to get the values out of the individual <TD> elements. Im dont need a routine to loop through them but simple a line of code to show me how to reference one.

Is it somethng like :

alert($(this).parent().parent('first TD').html());

thanks
           
jellydealAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

monasCommented:
<table>
  <tr>
     <td>
        ONE
     </td>
     <td>
        TWO
     </td>
     <td id="myTD">
        THREE
     </td>
  </tr>
</table>
<script>alert($("#myTD").parent().children('td').toArray()[0].innerHTML);</script>

Open in new window

0
chaitu chaituCommented:
  <table>
  <tr>
     <td>
        ONE
     </td>
     <td>
        TWO
     </td>
     <td id="myTD">
        THREE
     </td>
  </tr>
</table>
<script>alert($("#myTD").siblings('td')[0].innerHTML)</script> 

Open in new window

0
nap0leonCommented:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
  <title>Demo</title>
  <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript" ></script>
  <script type="text/javascript">
    function demoThis(obj_html){
      var myTDs = obj_html.children('td');
      alert('there are ' + myTDs.length + ' TDs');

      myTDs.each(function(){
        var TDtext = $(this).text();
        alert(TDtext);
      });
    }
  </script>
  <style>
  </style>
</head>
<html>
<table>
  <tr>
    <td>ONE</td>
    <td>TWO</td>
    <td>THREE</td>
  </tr>
  <tr>
    <td>AAA</td>
    <td>BBB</td>
    <td>CCC</td>
  </tr>
  <tr>
    <td colspan="3"><span onclick="javascript:demoThis($(this).parent().parent().parent().children());">click me</span></td>
  </tr
</table>
</html>

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
jellydealAuthor Commented:
Thanks :))))
0
nap0leonCommented:
That was kind of fun.  I found several ways of returning only the first TD's text, but none of them lent themselves to finding the text of the second or third TD.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.