var rows = jQuery("tbody tr");

rows.each(function(){
var row = jQuery(this);
row.click(function(event){
alert(row.children("td.hidden_url_field_for_track_list").text());
});
});

Sorry I missed a semicolon..

On Tue, Dec 23, 2008 at 12:21 PM, Cam Spiers <camspi...@gmail.com> wrote:

> var rows = jQuery("tbody tr");
>
> rows.each(function(){
> var row = jQuery(this)
> row.click(function(event){
> alert(row.children("td.hidden_url_field_for_track_list").text());
> });
> });
>
> Haven't tested but you could try something like this maybe.
>
>
> On Tue, Dec 23, 2008 at 11:40 AM, j0llyr0g3r <
> th3.gr31t.j0lly.r0...@googlemail.com> wrote:
>
>>
>> Hey guys,
>>
>> i'm having a hard time with jquery right now.
>>
>> Imagine the following simple table:
>>
>> CODE:
>>
>>         <table border='1' id='list_tracks_table'>
>>            <colgroup>
>>              <col width='40%' />
>>              <col width='20%' />
>>              <col width='20%' />
>>              <col width='20%' />
>>              <col width='0%' />
>>            </colgroup>
>>
>>            <thead>
>>              <tr>
>>                <th>Title</th>
>>                <th>
>>                  Genre
>>                </th>
>>                <th>
>>                  Speed
>>                </th>
>>                <th>
>>                  Length
>>                </th>
>>              </tr>
>>            </thead>
>>            <tbody>
>>              <tr>
>>
>>                <td>
>>                  Cocktail Lounge
>>                </td>
>>                <td>
>>                  Chill
>>                </td>
>>                <td>
>>                  126
>>                </td>
>>                <td>
>>
>>                  03:03
>>                </td>
>>                <td class='hidden_url_field_for_track_list'>
>>                  /mp3/stream/MM-MB-0030-COCKTAIL-LOUNGE-126BPM.mp3
>> ................
>>
>> As you can see, the last field of the row gets hidden via CSS.
>> Now i have defined an onclick-Handler for every row of the table like
>> this:
>>
>> CODE:
>>
>>        function addClickHandler(tableId)       {
>>
>>                var tableObj = document.getElementById(tableId);
>>                var tBody = tableObj.getElementsByTagName('TBODY');
>>                if(tBody){
>>                        var rows = tBody[0].getElementsByTagName('TR');
>>                }else{
>>                        var rows = tableObj.getElementsByTagName('TR');
>>                }
>>                for(var no=0;no<rows.length;no++){
>>                        rows[no].onclick = clickOnTableRow
>>                }
>>        }
>>
>> 'clickOnTableRow' looks like this:
>>
>> CODE:
>>
>>        function clickOnTableRow()
>>        {
>>          alert ("working!")
>>       }
>>
>> Now, clickOnTableRow() is working when i click on a table row (i can
>> see that because of the alert-box), but how can i now select the
>> contents of the last hidden field of this exact row?
>>
>> I tried it like this:
>>
>> CODE:
>>        function clickOnTableRow()
>>        {
>>                var foo =
>> jQuery(this).('hidden_url_field_for_track_list').text();
>>                console.info("content: " + foo);
>>        }
>>
>> but this gives me:
>>
>> "content: undefined"
>>
>> Then i tried:
>>
>>        function clickOnTableRow()
>>        {
>>                var foo = jQuery('hidden_url_field_for_track_list').text();
>>                console.info("content: " + foo);
>>        }
>>
>> but this gives me just:
>>
>> "content:"
>>
>> What am i doing wrong here?
>>
>>
>> But no
>
>
>

Reply via email to