Is it possible to Show Answer (or flip the card) via javascript?

Basically what the title says. Is it possible to flip the card, from the front side, to the back side, via javascript included in the card template?

I was thinking of something like sending an spacebar keydown event using dispatchEvent(), but I want to make sure that the principle is correct before I try writing a script for it.
But I think that the spacebar gives the signal to the Qt part of anki to flip the card, and not the webview part, so I’m uncertain about this approach.

Could someone suggest something that would work, or tell me if it is even possible?