Say I have a table:
1 2 Edit
-
Use jQuery.replaceWith()
$(document).ready(function() {
$('#mytable .edit').click( function() {
var tr = $(this).parent();
var new_row = '<tr class="new_row"><td>3</td><td>4</td><td>Save</td></tr>';
tr.replaceWith(new_row);
});
});
讨论(0)
-
jQuery's replaceWith()
. Example:
$(document).ready(function() {
$('#mytable .edit').click( function() {
var tr = $(this).parent();
var new_row = '<tr class="new_row"><td>3</td><td>4</td><td>Save</td></tr>'
tr.replaceWith(new_row); // code to replace this row with the new_row
});
} );
讨论(0)
-
http://jsfiddle.net/hAvyv/
$('.edit').click(function(){
$(this).parent().removeClass('old_row').addClass('new_row').html('<td>3</td><td>4</td><td>Save</td>');
});
讨论(0)
-
$(document).ready(function() {
$('#mytable .edit').click( function() {
var new_row = '<tr class="new_row"><td>3</td><td>4</td><td>Save</td></tr>'
$(this).parent().replaceWith(new_row);
});
} );
讨论(0)
- 热议问题