Skip to content

Commit 4cb97a1

Browse files
feat - utilizando função para calcular
1 parent e23cd8f commit 4cb97a1

File tree

3 files changed

+32
-109
lines changed

3 files changed

+32
-109
lines changed

Tabuada/css/style.css

Lines changed: 5 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -9,95 +9,6 @@ body {
99
background-color: #f2f2f2;
1010
}
1111

12-
.title {
13-
text-transform: uppercase;
14-
text-shadow: 2px 2px 2px #0002;
15-
}
16-
17-
.title a {
18-
color: #d07335;
19-
}
20-
21-
.content-center {
22-
width: 100%;
23-
max-width: 300px;
24-
margin: auto;
25-
padding: 25px;
26-
background-color: #fff;
27-
border-radius: 15px;
28-
box-shadow: 6px 6px 6px #0004;
29-
}
30-
31-
.content-center .text-center {
32-
text-align: center;
33-
}
34-
35-
.content-center img {
36-
width: 70%;
37-
}
38-
39-
.content-center form {
40-
margin: 20px;
41-
}
42-
43-
.content-center input,
44-
.content-center button {
45-
width: 100%;
46-
padding: 10px 5px;
47-
border: none;
48-
outline: none;
49-
}
50-
51-
.content-center input {
52-
border-bottom: 2px solid #ccc;
53-
margin-bottom: 10px;
54-
}
55-
56-
.content-center input:focus {
57-
border-bottom-color: #d07335;
58-
}
59-
60-
.content-center button {
61-
background-color: #d07335;
62-
color: #fff;
63-
border-radius: 5px;
64-
}
65-
66-
.content-center button:hover {
67-
background-color: #b55b28;
68-
cursor: pointer;
69-
}
70-
71-
.content-center button:active {
72-
background-color: #c14e0e;
73-
}
74-
75-
header a {
76-
color: #666;
77-
text-decoration: none;
78-
}
79-
80-
header a:visited {
81-
color: #000;
82-
}
83-
84-
header a:hover {
85-
text-decoration: underline;
86-
}
87-
88-
header h1 {
89-
font-size: 2.5em;
90-
text-align: center;
91-
margin: 50px auto;
92-
}
93-
94-
footer {
95-
font-size: 0.8em;
96-
text-align: center;
97-
margin: 20px auto;
98-
}
99-
100-
10112
.content-tab {
10213
width: 100%;
10314
text-align: center;
@@ -127,3 +38,8 @@ footer {
12738
background-color: rgba(0, 0, 0, .15);
12839
cursor: pointer;
12940
}
41+
42+
#valueA {
43+
width: 100%;
44+
padding: 10px;
45+
}

Tabuada/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
</head>
99
<body>
1010
<div class="content-tab">
11+
<input type="number" id="valueA" value="0">
1112
<table id="tab">
1213
<thead>
1314
<tr>

Tabuada/js/script.js

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,27 @@
1-
let tab = document.querySelector('#tab tbody')
2-
let valueA = 5
3-
tab.innerHTML = ''
4-
5-
for (let valueB = 0; valueB <= 10; valueB++) {
1+
function calc() {
2+
let tab = document.querySelector('#tab tbody')
3+
let valueA = parseInt(document.querySelector('#valueA').value)
4+
tab.innerHTML = ''
5+
6+
for (let valueB = 0; valueB <= 10; valueB++) {
67
let r = valueA * valueB
7-
8-
let tpl = `
9-
<tr>
10-
<td>${valueA}</td>
11-
<td>X</td>
12-
<td>${valueB}</td>
13-
<td>=</td>
14-
<td>${r}</td>
15-
</tr>
16-
`
17-
18-
let tr = document.createElement('tr')
19-
tr.innerHTML = tpl
20-
tab.append(tr)
21-
}
8+
9+
let tpl = `
10+
<tr>
11+
<td>${valueA}</td>
12+
<td>X</td>
13+
<td>${valueB}</td>
14+
<td>=</td>
15+
<td>${r}</td>
16+
</tr>
17+
`
18+
19+
let tr = document.createElement('tr')
20+
tr.innerHTML = tpl
21+
tab.append(tr)
22+
}
23+
}
24+
25+
calc()
26+
27+
document.querySelector('#valueA').addEventListener('change', calc)

0 commit comments

Comments
 (0)