I have a table, shown below:
<table id="paramsTable">
<tbody>
<tr>
<th>Name</th>
<th>Value <span style="color: Blue; cursor: pointer; font-size: smaller;" id="editParamValues">Edit</span></th>
<th>Type</th>
</tr>
<tr>
<td style="display: none;">1372</td>
<td>providername</td>
<td>BloombergFTP</td>
<td>String</td>
</tr>
<tr>
<td style="display: none;">1373</td>
<td>RateSetList</td>
<td>1020</td>
<td>String</td>
</tr>
<tr>
<td style="display: none;">1374</td>
<td>BloombergServer</td>
<td>CFC105</td>
<td>String</td>
</tr>
</tbody>
</table>
So now, that nifty little span, I have bound to this click event:
$('#editParamValues').live('click', function () {
alert('true');
});
Getting the alert, it works fine. However, I don't want to alert, I want that binded method to change all of the cells that are in the value
column to become textboxes filled with whatever their value is, so the user can edit them.
How would I do this?
$('#editParamValues').click(function () {
$('tr td:nth-child(3)').each(function () {
var html = $(this).html();
var input = $('<input type="text" />');
input.val(html);
$(this).html(input);
});
});
You don't even need Javascript/jQuery:
<table>
<tr>
<td><input type="text" value="My Thing"></td>
</tr>
</table>
input {
border:none;
}
input:active {
border:1px solid #000;
}
...just use CSS to style the input to look like a span.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With