Can you get card information using JavaScript?

Is it possible to get information about the current card (e.g., card id or deck name) using JavaScript? I mean a script inside the template.

You can get the deck name: Field Replacements - Anki Manual

1 Like

Thanks! {{Deck}} and {{Subdeck}} is exactly what I was looking for.

But is there a way to get the card id or something else to uniquely identify the current card without making a custom filter? I want it to work on mobile, so I can’t use python.

I am not sure if there may not be another easier option but one would be to add an ID with an addon or manually to your cards.

2 Likes

Thanks for the idea. While this isn’t ideal, it should work. I could add the id inside an invisible HTML object and then use JavaScript inside the template to find that object and retrieve the id. This is an extra step and the user could accidentally delete the id, but it’s better than nothing.

For this you don’t even have to create an element, you can just use {{ID_Field}} in your JavaScript.

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