I have application in ASP.NET with CheckBoxList:
<asp:CheckBoxList runat="server" ID="myCheckBoxList">
<asp:ListItem Text="1 16" />
<asp:ListItem Text="1 17" />
<asp:ListItem Text="2 20" />
</asp:CheckBoxList>
I want to change style for selected elements after button click. To do that I have JavaScript fuction:
function changeColor() {
var checkBoxList = document.getElementById("myCheckBoxList");
var options = checkBoxList.getElementsByTagName('input');
for (var i = 0; i < options.length; i++) {
console.log(options[i].checked);
if (options[i].checked) {
options[i].parentElement.className = 'Red';
}
}
}
When I click button, selected items change their colors for a very short moment (about 0,5 second) and then they back to default black color. Why my checkboxlist items style reset? I do not want this behaviour. How can I change my code to change color permamently (not just for 0,5 second)?