我有多个输入类型复选框 - 如果其中任何一个被选中,我想追加一列(只是一次) - 即使其他复选框类型在第一个复选框类型后标记,我不想再次添加列,它一直在做。我没有得到它每个复选框类型输入只添加一次。不过,我也希望只在整个文档中添加一列(即跨页面上的所有复选框)。我想选择复选框类型的输入,然后附加表列
这里的
<table id="edhist_table" >
<tr id="table_headings">
<th>Graduated?</th>
</tr>
<tr>
<td><input type="checkbox" name="college_grad" value="yes">yes</input></td>
</tr>
<tr id='grad_part'>
<td><input type="checkbox" name="grad_grad1" value="yes">yes</input></td>
</table>
<script>
//if any of the checkboxes are checked - shoudl append column
$("[type=checkbox]").one("click",function() {
$("#table_headings").append("<th id='degree_heading'>Degree/Certificate Name</th>");
任何想法非常赞赏的代码相关部分。
哦,我的天哪 - 谢谢你这使得完整意义上的 – user1769203 2013-04-05 19:38:04
实际上还有其他的方法可以检查,比如你不需要'length == 0'部分,但是我发现更明确的方式更容易理解。很高兴它对你有效。 – lucuma 2013-04-05 20:49:02