HTML结构:
<tr>
<td class="edit"><input type="checkbox" class="editbox" /></td>
<td class="content"><input type="text" class="contentbox" size="40" disabled="disabled"/></td>
<td class="delete"><input type="checkbox" class="deletebox" /></td>
</tr>
Run Code Online (Sandbox Code Playgroud)
我想要的是?当用户点击 input.editbox 时:
当用户点击 input.deletebox 时:
我为那个结构做了这个:
<input type="checkbox" class="editbox"/>
<input type="text" class="contentbox" size="40" disabled="disabled"/>
<input type="checkbox" class="deletebox"/>
Run Code Online (Sandbox Code Playgroud)
通过使用 .next() 和 .prev()
$(document).ready(function () {
$("#form input.editbox[type=checkbox]").each(function () {
$(this).change(function () {
if ($(this).is(":checked")) {
$(this).next().removeAttr("disabled");
$(this).next().next().attr('checked', false);
} else {
$(this).next().attr("disabled", "disabled");
}
});
});
$("#form input.deletebox[type=checkbox]").each(function () {
$(this).change(function () { …Run Code Online (Sandbox Code Playgroud)