HTML:
<table border="1px">
<tr>
<td colspan="2">
<div class="commentLink">
<a onclick="ShowBox.call(this); return false;" href="#">Comment</a>
</div>
</td>
</tr>
<tr class="commentBox" style="display: none;">
<td colspan="2">
<div class="hiddenComment">
<textarea class="textComment" rows="2" cols="100"></textarea>
<input class="foo" type="checkbox" />
<input class="commentBtn" type="button" value="Submit" onclick="addComment.call(this); return false;" />
<input class="commentBtn" type="button" value="Cancel" onclick="HideBox.call(this); return false;" />
</div>
</td>
</tr>
</table>
JS: using jquery 1.4.2
function ShowBox() {
var that = this;
$(function () {
$(".commentBox").show();
//$(that).closest('tr').siblings().show();
});
}
function HideBox() {
var that = this;
$(function () {
$(that).siblings(".foo").attr("checked", false);
$(that).siblings(".textComment").empty();
$(".commentBox").hide();
});
}
I have the two functions to show/hide a tr. The code I have now works, but it will close other elements too. What is the elegant way of doing this?