Exercise 10.3
This is Exercise 10.3, lecture on Javascript basics, used in the course IDATA2301 Web technologies at NTNU, campus Aalesund.
Purpose
The purpose of the exercise is to get familiar with event handling in Javascript: executing code on specific events, such as when the document is loaded, reacting on a button click or changed value in an input field. You will also practice using timers.
Instructions
Create a new HTML document, include a Javascript block there. Implement the following features:
- Create a function which prints the square root of 1764 in the console.
- Call this function when the document is loaded.
-
Print
"Hello, i"
(wherei
is a counter, incremented by one every time) to the console every second. - Add two buttons A and B. Print a message to the console (a different message for each button) whenever a button is pressed.
- Add a text input field. Whenever the text changes there, print a message in the console: "The text changed".
Solution
You can find a solution here.