Hide field based on the number of days of repetition

Hi. I want to hide the field if the days of repetition is more than 15. How to do it?

1 Like

This is possible by installing this addon and using javascript in your card template.

<div id="single-conditional-field">
  {{The field you want to conditionally hide}}
</div>
<script>
  pycmd("AnkiJS.ankiGetCardReps()", (repsCount) => { 
     const element = document.getElementById("single-conditional-field");
     if (repsCount > 15 && element) {
        // Hide the conditional field entirely
        element.style.display = "none";
     }
  });
</script>
  • The above code is for the desktop version of Anki
  • For AnkiDroid, the script part needs to be different
  • For AnkiMobile, I’m not sure if there is any way to do this with javascript as I don’t use AnkiMobile myself.
2 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.