How can I change the color of SVG lines from red to white using an onclick function in HTML?

How can I change the line color of an SVG to white from red using an onclick function that adds and removes classes? Currently, I can alter the background color but not the color of the SVG image itself. Here’s the SVG I’m working with:

<svg xmlns="" width="21" height="16" viewBox="0 0 21 16" fill="none">
  <!-- SVG content -->

I need the red color in the SVG to turn white when clicked. I thought using visibility: hidden would make the link unclickable, but it seems the click event from :hover still triggers after the tap. I’ve tried different CSS selectors without success.