如何使用JavaScript更改每行的状态
当我单击单选按钮时,span文本变为true或其他应为false,其工作正常,但当我单击不存在单选按钮时,需要将状态列转到发送,否则不发送如何使用JavaScript更改每行的状态,javascript,jquery,html,Javascript,Jquery,Html,当我单击单选按钮时,span文本变为true或其他应为false,其工作正常,但当我单击不存在单选按钮时,需要将状态列转到发送,否则不发送 $('table').on('change', ':radio', function () { $(this).next('span').text('True').closest('td').siblings().find('span').text('False'); $(this).next('span
$('table').on('change', ':radio', function () {
$(this).next('span').text('True').closest('td').siblings().find('span').text('False');
$(this).next('span').text('True').closest('td').siblings().find('label').text('Send');
});
Html
<tr>
<td><input type="radio" name="attandance"><span>True</span></td>
<td><input type="radio" name="attandance"><span>True</span></td>
<td><input type="radio" name="attandance"><span>True</span></td>
<td><label>NotSend</label></td>
</tr>
真的
真的
真的
诺森德
这是你理解我观点的图像。
注意
当我们单击缺席单选按钮时,只有状态变为Send,否则NotSend
提前谢谢。
代码日快乐 我只是在输入中添加了一个数据属性,以便能够识别它,然后在JS中使用它作为执行“特殊”操作的条件
$('table')。在('change','radio',function()上{
$(this).next('span').text('True').closest('td').sides().find('span').text('False');
$(this).next('span').text('True').closest('td').sides().find('label').text('NotSend');
//使用添加的数据
如果($(此).data(“不存在”)){
$(this).next('span').text('True').closest('td').sides().find('label').text('Send');
}
});代码>
目前
缺席的
离开
地位
真的
真的
真的
诺森德