I am helping someone fix their plain javascript highlight-when-checked
If you click yes or no, you will see it breaks and makes an unchecked row highlighted.
I know I could rewrite it in jQuery, but I would REALLY like to know what makes it fail
Thanks
It’s because you’re adding the classname every time. So if you change between yes/no 5 times, item3 will have classname
radio-item myclass myclass myclass myclass myclass. So in yourreplaceyou need to make sure it’s global (replacing every occurance of the search string)edit:
This code is adding the classname without checking if it’s there in the first place. Remember, you’re looping all checkboxes, for every change on any of them.