http://www.oschina.net/code/snippet_54100_2960
1. [代碼][JavaScript]代碼
1 | // Select all table cells to bind a click event |
2 | $( 'table td' ).click( function (){ |
3 |
$( this ).parent().remove(); |
4 | }); |
2. [代碼][HTML]代碼
01 | < table > |
02 |
< tr > |
03 |
< td >row 1, cell 1</ td > |
04 |
< td >< img class = "delete" src = "del.gif" /></ td > |
05 |
</ tr > |
06 |
< tr > |
07 |
< td >row 2, cell 1</ td > |
08 |
< td >< img class = "delete" src = "del.gif" /></ td > |
09 |
</ tr > |
10 | </ table > |
3. [代碼][JavaScript]代碼
1 | $( 'table td img.delete' ).click( function (){ |
2 |
$( this ).parent().parent().remove(); |
3 | }); |
4. [代碼][JavaScript]代碼
1 | $( 'table td' ).click( function (){ |
2 |
$.get( 'deleteRow.php' , {id: $( this ).parent().attr( 'id' )}, |
3 |
function (){ |
4 |
$( this ).parent().remove(); |
5 |
}); |
6 | }); |