r/learnjavascript • • Oct 21 '26

Function to inspect elements on anki

Hi!

First of all, I am not sure if this is the right sub.

But I was wondering if there was a way to add a function in an addon for an app (anki) that would let me know the "name" of the element I selected or clicked on, just like when pressing f12 on a web page.

The thing is that some elements I want to "find" come from an addon and not from anki directly.

4 Upvotes

5 comments sorted by

View all comments

1

u/Puzzleheaded-Comb646 Oct 22 '26

Since Anki uses web views for card templates and some add-ons, you can actually listen for click events using vanilla JavaScript. You can attach a listener to the document and use event.target.tagName or event.target.className to log the element you clicked on to the console.

javascript document.addEventListener('click', (e) => { console.log(e.target); });

This might help you identify those specific elements if they render inside an HTML context.