>1.input
新しいレイヤーに動的更新値を入力>
2.入力に表示されている値をレイヤーをクリックして、再度編集できるようにします。
http://jsfiddle.net/8yZhf/3/
しかし、私は2で立ち往生しています。$('.input').off("focus")
新しいレイヤーの追加(更新ではない)を回避するために使用する場合、
編集を終了するときに、以前と同じようにfocusout
回復するにはどうすればよいですか?focus
または他のより良いアイデア?
var layer;
$('.input').focus(function(){
layer = $('.input_insert').children('div').length + 1;
$('<div class='+layer+'></div>').appendTo('.input_insert');// add layer
$('.input_insert').children('div').click(function(e){
$('.input').val($(e.target).html());
// $('.input').off("focus");
})
return layer;// return layer count for keyup, focusout
})
$('.input').keyup(function(e){
$('.'+layer).html(this.value);
})
$('.input').focusout(function(){
$("input[class='input']").val('');
if($('.'+layer).html() == ''){// check if empty
$('.'+layer).remove();
}
})
HTML
<input type="text" class="input">
<div class="input_insert"></div>// container