File tree 3 files changed +32
-109
lines changed
3 files changed +32
-109
lines changed Original file line number Diff line number Diff line change 9
9
background-color : # f2f2f2 ;
10
10
}
11
11
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
-
101
12
.content-tab {
102
13
width : 100% ;
103
14
text-align : center;
@@ -127,3 +38,8 @@ footer {
127
38
background-color : rgba (0 , 0 , 0 , .15 );
128
39
cursor : pointer;
129
40
}
41
+
42
+ # valueA {
43
+ width : 100% ;
44
+ padding : 10px ;
45
+ }
Original file line number Diff line number Diff line change 8
8
</ head >
9
9
< body >
10
10
< div class ="content-tab ">
11
+ < input type ="number " id ="valueA " value ="0 ">
11
12
< table id ="tab ">
12
13
< thead >
13
14
< tr >
Original file line number Diff line number Diff line change 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 ++ ) {
6
7
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 )
You can’t perform that action at this time.
0 commit comments