-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
61 lines (47 loc) · 1.78 KB
/
index.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
const inputField = document.getElementById('inputField');
const outputField = document.getElementById('outputField');
inputField.addEventListener('keyup', getValue);
function getValue(){
outputField.innerHTML = inputField.value;
}
const uppercaseBtn = document.querySelector('.uppercase');
uppercaseBtn.addEventListener('click', () => {
return (outputField.innerHTML = outputField.innerHTML.toUpperCase());
});
document.querySelector('.lowercase').onclick=()=> {
return (outputField.innerHTML = outputField.innerHTML.toLowerCase());
}
document.querySelector('.capitalize').onclick = () => (outputField.innerHTML = outputField.innerHTML.charAt(0).toUpperCase() + outputField.innerHTML.slice(1).toLowerCase());
const boldBtn = document.querySelector('.bold');
boldBtn.addEventListener('click', () => {
if (boldBtn.classList.contains('active')){
boldBtn.classList.remove('acitve');
outputField.style.fontWeight = '400';
}
else {
boldBtn.classList.add('active');
outputField.style.fontWeight = '700';
}
})
const italicBtn = document.querySelector('.italic');
italicBtn.addEventListener('click', () => {
if (italicBtn.classList.contains('active')){
italicBtn.classList.remove('active');
outputField.style.fontStyle = 'none';
}
else {
italicBtn.classList.add('active');
outputField.style.fontStyle = 'italic';
}
});
const underlineBtn = document.querySelector('.underline');
underlineBtn.addEventListener('click', () => {
if (underlineBtn.classList.contains('active')){
underlineBtn.classList.remove('active');
outputField.style.textDecoration = 'none';
}
else {
underlineBtn.classList.add('active');
outputField.style.textDecoration = 'underline';
}
});