Auto-scroll to first cloze deletion on reveal

I’ve checked a few other posts, but can’t find a definitive answer. Currently, for simple cards with a front and a back, I have the following html:

<section id="answer" class="simple simple-reverse">

So on reveal the reverse card scrolls to the answer id. Is there any sane way to do this for a given {{c1::cloze field}}?

  1. I often have multiple cloze fields in one note
  2. Sometimes these are on the same card …
  3. Sometimes the note creates multiple cloze cards

Without javascript, is this possible (on AnkiMobile and desktop)? Or can I suggest a feature for this?

I guess you’d have to have numbered ids for each cloze card and scroll to the first one.

1 Like

Not possible without JavaScript.

1 Like

That’s a shame. I often have cards who’s cloze/answer are below the fold so can’t be seen very quickly. Is the javascript particularly involved to do this? I’d prefer not to use JS anyway though.

It’s actually pretty simple. This works for me in the front/back templates:

<script>
onUpdateHook.push(() => {
  document.querySelector(".cloze[data-ordinal='1']").scrollIntoView();
});
</script>
5 Likes

Cool. That seems quite straight forward thanks.

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