html - Get <tr> value from id with jquery -
<table cellpadding="0" cellspacing="0" border="0" class="display" id="example" > <thead> <tr> <th>project code</th> <th>project name</th> <th>project ref id</th> <th>effective date</th> <th>close date</th> <th>last update date</th> <th>creation date</th> <th>created by</th> <th>last update by</th> <th>action</th> </tr> </thead> <tbody> <?php //error_log(print_r($project,false)); for($i=0;$i<count($project);$i++) { ?> <tr class="project_id" value="<?php echo $project[$i] ['project_id']; ?>"> <td><?php echo $project[$i]['project_code']; ?></td> <td><?php echo $project[$i]['project_name']; ?></td> <td><?php echo $project[$i]['project_ref_id']; ?></td> <td><?php echo $project[$i]['effective_date']; ?></td> <td><?php echo $project[$i]['close_date']; ?></td> <td><?php echo $project[$i]['last_update_date']; ?></td> <td><?php echo $project[$i]['creation_date']; ?></td> <td><?php echo $project[$i]['created_by']; ?></td> <td><?php echo $project[$i]['last_update_by']; ?></td> <td><img class="edit" >src="http://spsvn01/raidlog/application/assets/img/file_edit.png" alt="edit" >border=1 height=20 width=20> <img class="delete" >src="http://spsvn01/raidlog/application/assets/img/notification_error.png" >alt="delete" border=1 height=20 width=20> </td> </tr> <?php } ?> </tbody> </table> <script type="text/javascript"> $(document).ready(function() { var table= $('#example').datatable( { "columndefs": [ { "width": "10%", "targets": 0 }] }); $('.delete').click(function () { var project_id = $('.project_id').val(); alert(project_id); }); } ); </script>
please want tr value , don't know how do..
$('.delete').click(function() { var project_id = $(this).closest('tr').attr('.value'); alert(project_id); }); .attr('value'); not .attr('.value');
this work fine.
Comments
Post a Comment