I'm facing a situation where I have a table that is logically divided into two halves, and I need to select only half of a row as shown in the image.
The challenge arises when I want to choose a different "half" row - in this case, I need to deselect the previously selected one. Below is the code snippet I am currently working with:
<tr class="line1">
<td width="10" class="td3523" onclick="selectme('3523');">
<input type="radio" name="selattendance" id="tr3523" onClick="setEditDelete(3523)"/>
</td>
<td width="100" class="td3523" onclick="selectme('3523');">2012-11-19</td>
<td width="125" class="td3523" onclick="selectme('3523');">
<table width="100%" cellpadding="0" cellspacing="0" style="border: 0;padding: 0;border-collapse: collapse">
<tr>
<td style="width: 50%;padding-right: 10px;border: 0" align="right" valign="middle">22:54</td>
<td style="width: 20%;border: 0"> <a href="#" onclick="loadPic('attendanceimages/39286a0a6b45cae9f116b11882f36046.jpg','2012-11-19','2012-11-19','add','','In','22:54:04','22:54:04');"><img src="images/punchimg.png"></a>
</td>
<td style="width: 20%;border: 0"> </td>
</tr>
</table>
</td>
</tr>
Currently, my click event on any td
selects all td
s with the same ID using the following JavaScript function:
function selectme(id) {
$('.td' + id).toggleClass("ui-selected");
}
To enhance this functionality, I believe I need to add a line of code to remove the "ui-selected" class from previously selected td
s. How can I achieve this? Thank you.