gpt4 book ai didi

javascript - 用于选中所有框的单选按钮

转载 作者:行者123 更新时间:2023-11-28 05:18:35 25 4
gpt4 key购买 nike

<table class="table borderless">
<thead>
<tr>
<th>Rank</th>
<th>+/-</th>
<th>Searches</th>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<td><input type="radio" name="optradio" class="custom"> ALL</td>
<td><input type="radio" name="optradio" class="custom"> ALL</td>
<td><input type="radio" name="optradio" class="custom"> ALL</td>
<td><input id="ex2" type="text" class="span2" value="" data-slider-min="10" data-slider-max="1000" data-slider-step="1" data-slider-value="[0,1000]" data-slider-id="RC" id="R"/></td>
</tr>
<tr>
<td><input type="checkbox" class="custom-selector"> Rank 1-10</td>
<td><input type="checkbox" > Up</td>
<td><input type="checkbox" > Over</td>
</tr>
<tr>
<td><input type="checkbox" class="custom-selector"> Rank 11-20</td>
<td><input type="checkbox" > Down</td>
<td><input type="checkbox" > Under</td>
</tr>
<tr>
<td><input type="checkbox" class="custom-selector"> Rank 21-100</td>
<td><input type="checkbox" > No movement</td>

</tr>
<tr>
<td><input type="checkbox" class="custom-selector"> Not in top 100</td>

</tr>
</tbody>
</table>

脚本:

$(document).ready(function () {
$(".custom").change(function () {
$(".custom").parent().find(".custom-selector").prop("checked", true);
})
});

我需要的是一个单选按钮,在选中时选中所有框。

现在当我点击单选按钮时没有任何反应。但是,如果我添加这个单选按钮:

<input type="radio" id="op5" value="1" name="options2" class="custom">

然后他们都工作了。即使是第一个检查所有框。

这是什么奇怪的行为?我错过了一些东西

编辑:看来单选按钮必须在表格外面?我能以某种方式把它放在里面吗?

最佳答案

尝试:

$(".custom").closest("tbody").find(".custom-selector").prop("checked", true);

或者只是:

$(".custom-selector").prop("checked", true);

关于javascript - 用于选中所有框的单选按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42022175/

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