Skip to content

Commit 3383717

Browse files
author
a.cheprasov
committed
The DOM and Type Casting
1 parent 9fb0704 commit 3383717

File tree

8 files changed

+44
-54
lines changed

8 files changed

+44
-54
lines changed

app.ts

Lines changed: 0 additions & 1 deletion
This file was deleted.

public/app.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
"use strict";
2+
// const anchor = document.querySelector('a')!;
3+
// // if (anchor) {
4+
// // console.log(anchor.href);
5+
// // }
6+
// console.log(anchor.href);
7+
var form = document.querySelector('.new-item-form');
8+
console.log(form.children);
9+
var type = document.querySelector('#type');
10+
var tofrom = document.querySelector('#tofrom');
11+
var details = document.querySelector('#details');
12+
var amount = document.querySelector('#amount');
13+
form.addEventListener('submit', function (e) {
14+
e.preventDefault();
15+
console.log(type.value, tofrom.value, details.value, amount.valueAsNumber);
16+
});

public/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,6 @@ <h1>Finance Logger</h1>
4343
<a href="https://www.thenetninja.co.uk">The Net Ninja</a>
4444
</footer>
4545

46-
<script src='sandbox.js'></script>
46+
<script src='app.js'></script>
4747
</body>
4848
</html>

public/sandbox.js

Lines changed: 0 additions & 22 deletions
This file was deleted.

public/test.js

Lines changed: 0 additions & 2 deletions
This file was deleted.

src/app.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// const anchor = document.querySelector('a')!;
2+
3+
// // if (anchor) {
4+
// // console.log(anchor.href);
5+
// // }
6+
7+
// console.log(anchor.href);
8+
9+
const form = document.querySelector('.new-item-form') as HTMLFormElement;
10+
console.log(form.children)
11+
12+
13+
const type = document.querySelector('#type') as HTMLSelectElement;
14+
const tofrom = document.querySelector('#tofrom') as HTMLInputElement;
15+
const details = document.querySelector('#details') as HTMLInputElement;
16+
const amount = document.querySelector('#amount') as HTMLInputElement;
17+
18+
form.addEventListener('submit', (e: Event) => {
19+
e.preventDefault();
20+
21+
console.log(
22+
type.value,
23+
tofrom.value,
24+
details.value,
25+
amount.valueAsNumber
26+
)
27+
})

src/sandbox.ts

Lines changed: 0 additions & 27 deletions
This file was deleted.

src/test.ts

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)