-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
30 lines (22 loc) · 959 Bytes
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
var userInput = document.getElementById('userInput');
var btnAddToList = document.getElementById('btnAddToList');
var itemList = document.getElementById('itemList');
function addItemToList() {
itemList.innerHTML += `<li>${userInput.value}</li>`;
userInput.value = '';
}
function addItemToListAfterPressEnter(event) {
if (userInput.value > 0 && event.keyCode === 13) {
addItemToList();
}
}
btnAddToList.addEventListener('click', addItemToList);
userInput.addEventListener('keypress', addItemToListAfterPressEnter);
var colorPicker1 = document.querySelector('#colorPicker1');
var colorPicker2 = document.querySelector('#colorPicker2');
var bodyColor = document.querySelector('body');
function colorPicker() {
bodyColor.style.backgroundImage = `linear-gradient(to right, ${colorPicker1.value} , ${colorPicker2.value} )`;
}
colorPicker1.addEventListener('input',colorPicker);
colorPicker2.addEventListener('input',colorPicker);