点击后制作标签文本框

far*_*jad -2 javascript label edit

我在网页上显示的表中有金额列.

我想要做的是当页面打开以显示金额作为标签.

当用户点击数量时,它就像文本框一样变得可编辑.

mel*_*okb 5

你的意思是这样的(使用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', '');
});
Run Code Online (Sandbox Code Playgroud)

示例演示:http://jsfiddle.net/LFgxr/