please me first cell value of each row in table click delete button, below codes display cell values cells. table generated ajax success function. table not exist on page on-load.
<script type="text/javascript"> $(document).ready(function() { $("#mytable td").click(function() { alert($(this).html()); }); }); </script> //html table , sample table , <table border="1" id="mytable"> <tr> <th>customer id</th> <th>action</th> </tr> <tr> <td>0001</td> <td><button>del</button></td> </tr> <tr> <td>0002</td> <td><button>del</button></td> </tr> <tr> <td>0003</td> <td><button>del</button></td> </tr> </table>
this looking for:
$("#mytable td").click(function () { var selectvalue = $(this).siblings("td").html(); alert(selectvalue); });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <table border="1" id="mytable"> <tr> <th>customer id</th> <th>action</th> </tr> <tr> <td>0001</td> <td><button>del</button></td> </tr> <tr> <td>0002</td> <td><button>del</button></td> </tr> <tr> <td>0003</td> <td><button>del</button></td> </tr> </table>
jsfiddle demo of code above.
Comments
Post a Comment