
我想知道“显示答案”的id是什么?我想在正面卡片的javascript中调用它;通过代码点击,实现显示答案。
Here is the code:
You can check it using this add-on: https://ankiweb.net/shared/info/31746032
By the way, I don’t think you can ‘click’ on the “Show answer” button by using JavaScript stored in the card template, because the bottom bar belongs to a separate webview.
What you can do is to use JavaScript to call the function that flips the card. For example:
<button onclick="showBack()">Flip Card</button>
<script>
function showBack()
{
if (typeof pycmd !== 'undefined') {
pycmd('ans');
}
}
</script>
The bottom bar is a different webview, so it’s not accessible by template scripts.
You can try calling pycmd("ans") instead. Check out this snippet in the AnKing notetypes:
在ankiDroid中不起作用,ankiDroid中不能实现吗?
AnkiDroid has different apis, please refer to the doc AnkiDroid Javascript API · ankidroid/Anki-Android Wiki · GitHub
Please note that pycmd() is an internal API and Anki does not provide a public API for accomplishing these things, so this is not guaranteed to keep working in future updates.


