I want to append the class red-border
to a tr
element which contains a span
with class warning
. My code is not working. Please help.
$(document).ready(function() {
$("body").css("width", "2000px");
$(".jsgrid-table").find(".warning").parents().addClass("red-border");
});
.red-border {
color: red;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<table class="jsgrid-table">
<tbody>
<tr class="jsgrid-row">
<td class="jsgrid-cell jsgrid-align-left" style="width: 100%;">2018</td>
<td class="jsgrid-cell jsgrid-align-left" style="width: 100%;"><span class="warning"></span></td>
</tr>
</tbody>
</table>