Skip to content

Commit 3bfe8ad

Browse files
committed
lesson-11
1 parent c0c3d22 commit 3bfe8ad

File tree

5 files changed

+45
-49
lines changed

5 files changed

+45
-49
lines changed

public/app.js

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

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.

src/app.ts

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

src/sandbox.ts

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

0 commit comments

Comments
 (0)