Javascript 更改jquery中的tr字段

Javascript 更改jquery中的tr字段,javascript,jquery,html,jquery-selectors,Javascript,Jquery,Html,Jquery Selectors,我正在尝试将“是”更改为“选择”下拉列表,允许用户选择“是”或“否” html是这样的: <tr> <td> text </td> <td>no(must be changed by js)</td> <td><a href="#">My button</a></td> </tr> <tr> <td> text </td> <td&g

我正在尝试将“是”更改为“选择”下拉列表,允许用户选择“是”或“否”

html是这样的:

<tr>
<td> text </td>
<td>no(must be changed by js)</td>
<td><a href="#">My button</a></td>
</tr>

<tr>
<td> text </td>
<td>yes(must be changed by js)</td>
<td><a href="#">My button</a></td>
</tr>
...
$('a[href="#"]').click(function() {...} });

正文
否(必须由js更改)
正文
是(必须由js更改)
...
$('a[href=“#“]”)。单击(函数(){…});
我想将按钮前面“是”的内容更改为下拉列表按钮的href值,单击该按钮可在后面进行一些处理

我试过了,但在警报后不起作用…:

<script type="text/javascript">
    //to make the authority editable
    $('a[href="#"]').click(function() {
        var select = this.parentElement.parentElement;
        alert(select);
        select: nth - child(2).apped("hello");
    });
 </script>

//使权限可编辑
$('a[href=“#“]”)。单击(函数(){
var select=this.parentElement.parentElement;
警报(选择);
选择:nth-child(2).apped(“hello”);
});

感谢您的帮助:-)

如果您的表中只有两个类似于上面HTML标记的
tr
,您可以像这样使用

$('a[href="#"]').click(function() {
    var select = this.parentElement.parentElement;
    alert(select);
    $('tr:eq(1) td:eq(1)').append("hello");
});
此外,您可能正在寻找而不是
.append()
来更改
td
中的文本:

$('tr:eq(1) td:eq(1)').text("hello");
您可以使用和遍历方法

$('a[href="#"]').click(function() {
    $(this).parent().prev().html('xxx')
});
演示:


如果要使用,需要找到单击按钮的
tr
,然后使用


演示:

Hi@Felix。谢谢你的回答。我没有说过,但是tr的数量取决于te数据,所以我不能使用你的技术,但非常感谢!你好,阿伦!谢谢你的回答,这是解决方案:-)此外,我想更改链接,所以我只需在你的.html('xxx')之后添加$(this.attr(“href”):-)谢谢!
jQuery(function () {
    $('a[href="#"]').click(function () {
        $(this).closest('tr').find(':nth-child(2)').html('xxx')
    });
})