gpt4 book ai didi

javascript - 我如何使用 Jquery/JS 获取此元素?

转载 作者:行者123 更新时间:2023-11-30 00:29:56 26 4
gpt4 key购买 nike

我正在尝试使用按钮上的 onclick 事件将上一个“已显示”行添加到该行。我正在使用数据表,数据表展开以显示在“已显示”行之后插入的行中的子项。

例如

<tr role="row" class="odd shown"> <!-- I want to get this row by it's class/role -->
<tr><tr> <!-- This is a comment row with a button that submits aforementioned comments -->
<tr role="row" class="even"> <!-- This row is not expanded -->

这里所说的是我实际代码的相当大一部分(减去 js)。

<tr role="row" class="odd shown">
<td class=" details-control"></td>
<td class="sorting_1"></td>
</tr>
<tr>
<td colspan="7">
<div style="text-center">
<table class="table" style="background:transparent;width:100%;">
<tbody>
</tbody>
</table>
</div>
<br>

<div class="container text-center col-md-offset-2 col-md-8" id="commentDiv"><label for="applicantComment"><h4>
Add comment</h4></label><br><textarea class="form-control" id="applicantComment1"
style="resize:none;width:100%;height:100px;"></textarea>

<div><br></div>
<div class="container text-center col-md-offset-2 col-md-8" style="width:inherit;">
<div class="intro-text"><a class="btn btn-xl" value="1" id="submit">Submit</a></div>
</div>
</div>
</td>
</tr>
</tbody>

最佳答案

您想向上移动到最近的 <tr>然后根据我的理解得到上一行

$('.btn-xl').click(function(){
var $shownRow = $(this).closest('tr').prev();
$shownRow.doSomething();
});

关于javascript - 我如何使用 Jquery/JS 获取此元素?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29980128/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com