For detailed JavaScript tutorials, and as a great reference, see W3Schools JavaScript section.
Go through the JS Tutorial, and stop before you get to the JS Forms.
Here is an example I'll talk through:
Start with a web page test_javascript.html
:
.. literalinclude:: test_javascript.html :linenos: :language: html
In the same directory, create your JavaScript file test_javascript.js
:
.. literalinclude:: test_javascript.js :linenos: :language: javascript