<td>
ユーザーが要素をダブルクリックすると、次のようになるようにコードを記述しました。
<input>
の午前を追加type="text"
- それに値を追加し、ユーザーが入力をクリックすると更新します
ここに私の問題があります:
ユーザーがダブルクリックしてEnterキーを押さず<td>
に別のものをクリックした場合、イニシャルを以前の値にリセットする必要があります。<td>
<td>
<input>
// Selecting the table <th> odd elements
$("#div table td").dblclick(function(){
var currentEle = $(this);
var value = $(this).html();
updateVal(currentEle, value);
});
function updateVal(currentEle, value)
{
$(currentEle).html('<input class="thVal" type="text" value="'+value+'" />');
$(".thVal").focus();
$(".thVal").keyup(function(event){
if(event.keyCode == 13){
$(currentEle).html($(".thVal").val().trim());
}
});
$('body').not(".thVal").click(function(){
if(('.thVal').length != 0)
{
$(currentEle).html($(".thVal").val().trim());
}
});
}
私を助けてください。私はjeditable datatableを使いたくありません。