gpt4 book ai didi

jquery - 启用单个复选框

转载 作者:行者123 更新时间:2023-12-01 04:49:22 24 4
gpt4 key购买 nike

我想要实现的目标:单击文档(即文档 1)后,我希望启用该文档右侧的框,以便用户可以检查它。但是,目前的设置是,如果用户单击文档 1,则所有框都会启用。

我只是使用文档 1 作为示例,但我希望每个文档链接都如此。有人可以帮忙吗?

我做了一些研究,但找不到针对此特定问题的任何修复方法。

我当前的代码:

<!DOCTYPE html>
<html>

<head>
<style>
table, th, td
{

border:1px solid black;
border-collapse:collapse;
}
</style>

<script src="http://code.jquery.com/jquery-latest.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function() {
$("a").click(function() {
$("input").removeAttr("disabled");
});
});
</script>

</head>

<body>

<form method="post" action="mailto:@null">
<table style="width:500px">
<tr>

<td><a href="https://null" target="_d1">Document 1</a>
<td><input type="checkbox" name="name1" value="D1" disabled></td>
</tr>
<tr>
<td><a href="https://null" target="_d2">Document 2</a></td>
<td><input type="checkbox" name="name1" value="D2" disabled></td>
</tr>
<tr>
<td><a href="https://null" target="_d3">Document 3</a></td>
<td><input type="checkbox" name="name1" value="D3" disabled></td>
</tr>
<tr>
<td><a href="https://null" target="_d4">Document 4</a></td>
<td><input type="checkbox" name="name1" value="D4" disabled></td>
</tr>
<tr>
<td><a href="https://null" target="_d5">Document 5</a></td>
<td><input type="checkbox" name="name1" value="D5" disabled></td>
</tr>
<tr>
<td><a href="https://null" target="_d6">Document 6</a></td>
<td><input type="checkbox" name="policyAcknowledgement" value="D6" disabled></td>
</tr>
</table>

<input type="submit">
<input type="reset">
</form>

</script>
</body>
</html>

最佳答案

将 jQuery 更改为:

$("a").click(function (e) {
e.preventDefault();
$(this).parent().next().find('input').removeAttr("disabled");
});

<强> jsFiddle example

关于jquery - 启用单个复选框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23317115/

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