Hi all,
I am using Anki for language learning. As part of it, I have a script set-up to change the background colour of the back of a card if the card is a gendered noun.
The styling is set-up to have a white background unless changed by the script.
The script is:
<script>
var g = document.getElementById(“gender”).textContent;
var bg = document.querySelector(“.card”);
if (g == “m”) {
bg.style.backgroundColor = “#96C4E4”;
} else if (g == “f”) {
bg.style.backgroundColor = “#DC9097”;
} else if (g == “t”) {
bg.style.backgroundColor = “#f7d3bb”;
}else if (g == “c”) {
bg.style.backgroundColor = “#c8bfe7”;
}else if (g == “p”) {
bg.style.backgroundColor = “#915f64”;
}
</script>
For example, for a masculine noun Front->Back Card.
Front Card: White Background
Back Card: Blue Background
The issue I am having, is that when I action the card (Again, Good, etc.), the background of the next card remains blue.
This only does not happen if it gives me a Back->Front card with that script enabled to change to a different colour.
I want it to turn back to the original white background once the next card appears.
This issue occurs both when working on the cards, and when flipping between “front preview” and “back preview” when editing the card - so it appears to be something built into Anki causing this problem.
Is there a simple script line I can put onto the front of the card to force Anki to return the card to the white background?
I have tried using a <divstyle="card"></div>
to wrap around the front template, but then it causes only a rectangular section of the card to return to white - enough to encompas the whole “card” - but the remainder of the screen background remains to that changed colour.
I do not have this issue on AnkiDroid, only with Anki desktop.
Many thanks for any help you can provide!