JAVASCRIPT IN FLASHCARDS

34 views
Skip to first unread message

Fabio Rivolta

unread,
Dec 6, 2023, 7:52:57 AM12/6/23
to public...@ankidroid.org
Hello everyone, 
first of all thank you for making this wonderful App available!
Then I might have an issue: I'm trying to learn JavaScript and I like embedd some lines of code into the html of the flashcards, but it doesn't seem to work.

<DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Color Changer</title>
  <script>
    function changeColor() {
      var color = document.querySelector('input[name="color"]:checked').value;
      document.getElementById('textArea').style.color = color;
    }
  </script>
</head>
<body>

  <label>
    <input type="radio" name="color" value="red" onclick="changeColor()"> Red
  </label>

  <label>
    <input type="radio" name="color" value="blue" onclick="changeColor()"> Blue
  </label>

  <br>

  <textarea id="textArea" rows="4" cols="50">This text will change color</textarea>

</body>
</html>

Like here the html will display correctly but clicking on the Radio Button, the Text color won't change.
Am I getting something wrong?
Thank you in advance for your help and, again, wonderful app!

Fabio 

Mike Hardy

unread,
Dec 6, 2023, 7:54:45 AM12/6/23
to anki-a...@googlegroups.com


Hi there - we've enabled WebView debugging in the app and this is the way to go - live inspection while executing so you can develop rapidly: https://github.com/ankidroid/Anki-Android/wiki/Development-Guide#html-javascript-inspection

--
You received this message because you are subscribed to the Google Groups "AnkiDroid" group.
To unsubscribe from this group and stop receiving emails from it, send an email to anki-android...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/anki-android/CAKOcX4qTSgKPnbAJQvwd2xdLk75ECdW2JZrGNQ1p5a73CCNnVA%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages