In jQuery get neighboring cell Data (Same Row) for each row link -


i have table structure

<table>   <tr>     <td class="idcol">         data...     </td>     <td class="linkcol">         <a href="..">link</a>     </td>     <!-- etc. -->   </tr> </table> 

a jquery iterator needs go through links , capture neighboring data in corresponding column idcol left:

$('#mytable a[id^="linkindex"]').off("click.linkindex").on("click.linkindex", function() {    // here, need corresponding "idcol" contents link row    var idcontents = ...; }); 

is there easy way this?

assuming a[id^="linkindex"] selector correct, try :

$('#mytable a[id^="linkindex"]').off("click.linkindex").on("click.linkindex", function() {    var idcontents = $(this).closest("td").prev("td.idcol").text(); // or maybe .html() }); 

Comments

Popular posts from this blog

android - net_scheduler holding wakelock -

sql - MySQL : Getting Entries from a many-to-many table -

java - Retrieving data from database using jsp (Hibernate + Spring + Maven) -