I need to change the color of a row in my Datatable when I click on the button 'APPLY'
Here is my HTML code for the rows :
<tr role="row" class="odd"></tr>
<tr role="row" class="even selected"></tr>
<tr role="row" class="odd"></tr>
<tr role="row" class="even"></tr>
In my inspect tab I can change the background color of the row like this :
table.dataTable tbody tr.selected {
background-color: orange;
}
How can I code this in Javascript? I tried this code but I obtained an error :
$("#btnApply").click(function() {
var zz = document.getElementsByClassName("selected");
zz.style.backgroundColor = "orange";
});
The error :
Uncaught TypeError: Cannot set property 'backgroundColor' of undefined
zzis array-like, tryzz[0].style.backgroundColor