remove row on click on specific td of that row by jquery

Posted by I Like PHP on Stack Overflow See other posts from Stack Overflow or by I Like PHP
Published on 2010-03-27T07:35:53Z Indexed on 2010/03/27 7:43 UTC
Read the original article Hit count: 150

Filed under:
|

i have an table

<table class="oldService">
    <thead>
           <th>name</th>
           <th>age</th>
           <th>action</th>
    </thead>    
    <tbody>
    <?php foreach($array as $k=>$v){ ?>       
          <tr>
              <td><?php echo $k[name] ?></td>
              <td><?php echo $k[age]?></td>
              <td id="<?php $k[id]" class="delme">X</td>
          </tr>
    <?php } ?>        
    </tbody>
<table>

now i want to delete any row by clicking on X of each row except first and last row, and also need to confirm before deletion.

i used below jquery

<script type="text/javascript">
jQuery(document).ready(function(){
    jQuery('table.oldService>tbody tr').not(':first').not(':last').click(function(){
    if(confirm('want to delete!')){
    jQuery(jQuery(this).addClass('del').fadeTo(400, 0, function() { 
            jQuery(this).remove()}));
    jQuery.get('deleteService.php', {id:jQuery(this).attr('id')});
    }
    else return false;});
});

</script>

this is working perfect,but it execute by click on that row( means any td), i want that this event only occour when user click on X(third td) . please suggest me how to modify this jquery so that the event occur on click of X.

© Stack Overflow or respective owner

Related posts about php

Related posts about jQuery