make a label textbox after click [closed]
i have amount column in a table that shows on web page.
what i want to do is when page open up to show amount as label.
when user clicks on the amount it becomes editable like textbox.
Do you mean something like this (using jQuery):
<span id="amount">3.25</span>
<input id="amount_entry" name="amount" style="display:none;"></input>
$('#amount').click(function() {
$('#amount').css('display', 'none');
$('#amount_entry')
.val($('#amount').text())
.css('display', '')
.focus();
});
$('#amount_entry').blur(function() {
$('#amount_entry').css('display', 'none');
$('#amount')
.text($('#amount_entry').val())
.css('display', '');
});
Sample demo: http://jsfiddle.net/LFgxr/
精彩评论