How to append a textbox to a table row with jQuery?
How to append a textbox to a table ro开发者_如何学Cw with jQuery?
How can you append an input type to a table row? You have to append it to a table cell, if not you can position it absolute at the position of the table row. You can't append it to a row via the DOM,
Seeing your other question, why don't you add an input type hidden to the first cell of the row? You could easily do this like this:
$('tr#id td:first').append($('<input type="hidden" id="hidden_field" name="hidden_field" value="your value" />'));
Use the append()
function.
var tr = getItSomehow();
var textbox = $('<input type="text" id="foo" name="foo">');
tr.append(textbox);
See also:
- jQuery
append()
documentation
Give the destination element and ID. Then:
$('#destinationId').append('<input type="text" name="newBox" />');
精彩评论