HTML structure:
<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>
What I want? When user clicks on input.editbox:
- input.contentbox became editable
- input.deletebox became unchecked (if was checked before)
When user click on input.deletebox:
- input.contentbox became disabled
- input.editbox became unchecked (if was checked before)
I did this for that structure:
<input type="checkbox" class="editbox"/>
<input type="text" class="contentbox" size="40" disabled="disabled"/>
<input type="checkbox" class="deletebox"/>
by using .next() and .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 () {
if ($(this).is(":checked")) {
$(this).prev().attr("disabled", "disabled");
$(this).prev().prev().attr('checked', false);
}
});
});
});
But now can't convert jQuery code for new structure. Any help and ideas are greatly appreciated.