Javascript 点击更改为不同的tr

Javascript 点击更改为不同的tr,javascript,jquery,html,Javascript,Jquery,Html,使用Jquery,我有一个表,单击表行,我希望td更改为文本框或下拉列表 输入textbox的值后,我希望这些值更新到单击它的表行。我有一部分 请帮我做这个 这是我的html代码: <table id="myTable" > <tr> <td></td> <td></td> <td></td> <td></td> <td></td> </

使用Jquery,我有一个表,单击表行,我希望td更改为文本框或下拉列表

输入textbox的值后,我希望这些值更新到单击它的表行。我有一部分

请帮我做这个

这是我的html代码:

<table id="myTable" >
<tr>
 <td></td>
 <td></td>
 <td></td>
 <td></td>
 <td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
 <td></td>
   </tr>
</table>

这是我的剧本:

$(document).ready(function () {
$("#myTable").children("tbody").children("tr").children("td").click(function () {
    $(this.parentNode).replaceWith('<tr><td ><textarea></textarea></td><td ><textarea></textarea></td><td ><textarea></textarea></td></tr>').appendTo($(this)).val().select().blur(function () {
        var newText = $(this).val();
        $(this).parent().text(newText);
    });
});
});
$(文档).ready(函数(){
$(“#myTable”).children(“tbody”).children(“tr”).children(“td”)。单击(函数(){
$(this.parentNode).replaceWith(“”).appendTo($(this)).val().select().blur(函数(){
var newText=$(this.val();
$(this.parent().text(newText);
});
});
});

试试这样的方法。我不检查它是否编译,这只是一个想法:

$("#myTable").children("tbody").children("tr").children("td").click(function () {
    var cell1Text = $(this).find('.cell1').text();
    $(this.parentNode).replaceWith('<tr><td><textarea class="cell1">'+cell1Text+'</textarea></td>...</tr>').appendTo($(this)).val().select().blur(function () {
        var newText = $(this).val();
        $(this).parent().text(newText);
    });
})
.blur(function () {
    var cell1Val = $(this).find('.cell1').val();
    $(this.parentNode).replaceWith('<tr class="cell1">'+cell1Val+'<td ></td>...</tr>').appendTo($(this)).val().select().blur(function () {
        var newText = $(this).val();
        $(this).parent().text(newText);
    });
});
$(“#myTable”).children(“tbody”).children(“tr”).children(“td”)。单击(函数(){
var cell1Text=$(this.find('.cell1').text();
$(this.parentNode).replaceWith(“”+cell1Text+“…”).appendTo($(this)).val().select().blur(函数(){
var newText=$(this.val();
$(this.parent().text(newText);
});
})
.blur(函数(){
var cell1Val=$(this.find('.cell1').val();
$(this.parentNode).replaceWith(“”+cell1Val+“…”).appendTo($(this)).val().select().blur(函数(){
var newText=$(this.val();
$(this.parent().text(newText);
});
});