0
我創建了一個PHP foreach
循環表;現在我試圖用單擊input
替換td
中的值。<input>失去焦點
$('#memberTable tr td').click(function(e){
$(this).html('<input type="text" id="" size="20" value=""/>');
});
輸入樣式只在:focus
上閃爍一次,然後失去焦點。
我創建了一個PHP foreach
循環表;現在我試圖用單擊input
替換td
中的值。<input>失去焦點
$('#memberTable tr td').click(function(e){
$(this).html('<input type="text" id="" size="20" value=""/>');
});
輸入樣式只在:focus
上閃爍一次,然後失去焦點。
你可以把它集中與.focus()
:
$('#memberTable tr td').click(function(e) {
var $this = $(this);
$this.empty();
$('<input />', {
type: 'text',
id: '',
size: 20,
value: $this.text()
}).appendTo($this).focus();
});
嘗試手動調焦它:
var input = $('<input type="text" id="" size="20" value="" />');
$(this).empty().append(input);
input.focus();
它只是顯示有'焦點()'風格,打字不工作 – NestedWeb
@NestedWeb :對我來說工作得很好(稍作改動):http://jsfiddle.net/S4PVY/3/ – Blender