BananaMaster

9 - Input (date, color) in JavaScript (style.background) | JS lessons

If you forgot something — click to go to the lesson.

Task 1.

Create an input with type="number" and a button. When the button is clicked, display the entered number increased by 5.

Task 2.

Create two inputs with type="number". When the button is clicked, display their difference (first minus second).

Task 3.

Create an input with type="date" and a button. When the button is clicked, display the selected date.

Task 4.

Create an input with type="date", a button, and an empty <ul> with the class .out-4. The user selects a date. When the button is clicked, create a new <li> element with the selected date and add it to the list. Use string concatenation ('<li>' + ...) and shorthand syntax. Each click should add a new list item.

Task 5.

Create an input with type="color" and a button. When the button is clicked, display the selected color in a div as text. The output will look like #0f0f0f (may vary slightly depending on the browser).

Task 6.

Create an input with type="color" and a button. When the button is clicked, change the button's background color to the selected color from the input. Use (style.background =).

Task 7.

Create an input with type="color" and a button. When the button is clicked, change the button's text color to the selected color from the input. Use (style.color =).

Task 8.

Create an input with type="color", an <h1> element with the text "Hello", and a button. When the button is clicked, change the background color of the h1 text to the selected color. Use (style.background =).

Task 9.

Create three inputs with type="number" and a button. When the button is clicked, log the average of the three numbers to the console. Formula: (inp1 + inp2 + inp3) / 3