Need to highlight the entire row when check box is checked and remove highlight when unchecked. My current code highlights just the check box cell not the entire row. HElp!
JSP:
<tbody> <c:forEach items="${summary}" var="summary"> <tr> <td bgcolor='<c:out value="${summary.color}"></c:out>'><c:out value="${summary.eventDesc}" /> </td> <td bgcolor='<c:out value="${summary.color}"></c:out>'><a href="/analysis/loadAnalysisDetailFromSummary?labelNbr=${summary.labelNbr}&loadDate=${summary.loadDate}"><c:out value="${summary.labelNbr}" /> </a> </td> <td bgcolor='<c:out value="${summary.color}"></c:out>'><c:out value="${summary.origin}" /> </td> <td bgcolor='<c:out value="${summary.color}"></c:out>'><c:out value="${summary.senderName}" /> </td> <td bgcolor='<c:out value="${summary.color}"></c:out>'><c:out value="${summary.receiverName}" /> </td> <td bgcolor='<c:out value="${summary.color}"></c:out>'><c:out value="${summary.receiptDate}" /> </td> <td bgcolor='<c:out value="${summary.color}"></c:out>'><c:out value="${summary.loadDate}" /> </td> <td bgcolor='<c:out value="${summary.color}"></c:out>'><c:out value="${summary.forecastIsc}" /> </td> <td bgcolor='<c:out value="${summary.color}"></c:out>'><c:out value="${summary.actualIsc}" /> </td> <td bgcolor='<c:out value="${summary.color}"></c:out>'><c:out value="${summary.country}" /> </td> <td id="td1" bgcolor='<c:out value="${summary.color}"></c:out>'><c:out value="${summary.source}" /> </td> <c:if test="${isAll == 'false'}"> <td align='center' bgcolor='<c:out value="${summary.color}"></c:out>'> <input name='summaryCheckbox' type="checkbox" class="cbx" value='<c:out value="${summary.labelNbr}"></c:out>,<c:out value="${summary.loadDate}"></c:out>, <c:out value="${summary.eventInd}"></c:out>'> </td> </c:if> </tr> </c:forEach> </tbody> Jquery:
$(document).ready(function(){ $("input[type='checkbox']").change(function(e) { if($(this).is(":checked")){ $(this).closest('td').addClass("highlight"); } else{ $(this).closest('td').removeClass("highlight"); } }); }); CSS:
table{border: 1px solid;} .highlight{background: #C0C0C0;}