# Can you get card information using JavaScript?

**URL:** <https://forums.ankiweb.net/t/can-you-get-card-information-using-javascript/29276>\
**Category:** Development\
**Created:** [April 11, 2023, 5:13pm UTC](https://forums.ankiweb.net/t/can-you-get-card-information-using-javascript/29276 "2023-04-11T17:13:26Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![RonX](https://avatars.discourse-cdn.com/v4/letter/r/50afbb/32.png) [@RonX](https://forums.ankiweb.net/u/RonX)\
**Post date:** [April 11, 2023, 5:13pm UTC](https://forums.ankiweb.net/t/can-you-get-card-information-using-javascript/29276/1 "2023-04-11T17:13:26Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![dae](https://sea2.discourse-cdn.com/flex002/user_avatar/forums.ankiweb.net/dae/32/65_2.png) [@dae](https://forums.ankiweb.net/u/dae)\
**Post date:** [April 12, 2023, 12:27am UTC](https://forums.ankiweb.net/t/can-you-get-card-information-using-javascript/29276/2 "2023-04-12T00:27:38Z")

</div>

You can get the deck name: [Field Replacements - Anki Manual](https://docs.ankiweb.net/templates/fields.html#special-fields)

---

<div class="post-metadata">

**Author:** ![RonX](https://avatars.discourse-cdn.com/v4/letter/r/50afbb/32.png) [@RonX](https://forums.ankiweb.net/u/RonX)\
**Post date:** [April 14, 2023, 10:58am UTC](https://forums.ankiweb.net/t/can-you-get-card-information-using-javascript/29276/3 "2023-04-14T10:58:36Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![FileX](https://sea2.discourse-cdn.com/flex002/user_avatar/forums.ankiweb.net/filex/32/14030_2.png) [@FileX](https://forums.ankiweb.net/u/FileX)\
**Post date:** [April 15, 2023, 3:30pm UTC](https://forums.ankiweb.net/t/can-you-get-card-information-using-javascript/29276/4 "2023-04-15T15:30:35Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![RonX](https://avatars.discourse-cdn.com/v4/letter/r/50afbb/32.png) [@RonX](https://forums.ankiweb.net/u/RonX)\
**Post date:** [April 16, 2023, 9:47pm UTC](https://forums.ankiweb.net/t/can-you-get-card-information-using-javascript/29276/5 "2023-04-16T21:47:41Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![FileX](https://sea2.discourse-cdn.com/flex002/user_avatar/forums.ankiweb.net/filex/32/14030_2.png) [@FileX](https://forums.ankiweb.net/u/FileX)\
**Post date:** [April 17, 2023, 2:38pm UTC](https://forums.ankiweb.net/t/can-you-get-card-information-using-javascript/29276/6 "2023-04-17T14:38:45Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex002/uploads/anki2/original/1X/8f1279ababc5879d54e4838989f606cfe55af8c7.jpeg) [@system](https://forums.ankiweb.net/u/system)\
**Post date:** [May 17, 2023, 2:39pm UTC](https://forums.ankiweb.net/t/can-you-get-card-information-using-javascript/29276/7 "2023-05-17T14:39:37Z")

</div>

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