get the second td value in dynamically generated datatable

datatable, jquery

Solution

Your question is not clear. But, after reading the comments, I think this is what you need.

$(".checker input").change(function(){
    if(this.checked){
        var value = $(this).closest("tr").find("td:eq(1)").find("a").text();
        alert(value);
    }

});

You can try it here.

http://jsfiddle.net/augusto1982/XPLx7/

Note: Using the `closest` method is a neat way of avoiding `parent().parent()...parent()` in your code.

Problem

On my webpage, I have a button whose click dynamically generates a table. Each row of the table has a radio button. Now, I am trying to get the checked radio button nearest td value.. I mean the amount value.. ``` <table cellpadding="0" cellspacing="0" width="100%" class="table table-bordered table-striped "> <thead> <tr> <th> <div class="checker"><span><input type="checkbox" class="checkall"></span> </div> </th> <th>Amount</th> <th>Agg Starts</th> <th>Agg Ends</th> <th>Next Renewal</th> <th>Term</th> </tr> </thead> <tbody> <tr> <td> <div class="checker"><span class=""><input type="checkbox" name="checkbox" class="ads_Checkbox" value="2"></span> </div> </td> <td><a class="show_hide1" href="" id="ah">1200000</a> </td> <td>15-01-2013</td> <td>31-12-2013</td> <td>01-01-2014</td> <td>1</td> </tr> <tr> <td> <div class="checker"><span class="checked"><input type="checkbox" name="checkbox" class="ads_Checkbox" value="65"></span> </div> </td> <td><a href="" id="ah">200</a> </td> <td>19-11-2013</td> <td>19-11-2013</td> <td>24-11-2013</td> <td>2</td> </tr> </tbody> </table> ```

Original source

Related problems