A project created by Hatem Hosny on LiveCodes.
Created
November 1, 2021 23:49
-
-
Save hatemhosny/16974dd2168231f66fcfdc910d848abc to your computer and use it in GitHub Desktop.
Untitled Project
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="container"> | |
<h1>Hello, <span id="title">World</span>!</h1> | |
<img class="logo" src="http://127.0.0.1:8080/livecodes/assets/templates/typescript.svg" /> | |
<p>You clicked <span id="counter">0</span> times.</p> | |
<button id="counter-button">Click me</button> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Counter { | |
private count: number; | |
constructor() { | |
this.count = 0; | |
} | |
increment() { | |
this.count += 1; | |
} | |
getValue() { | |
return this.count; | |
} | |
} | |
const title = document.querySelector("#title"); | |
const count = document.querySelector("#counter"); | |
const button = document.querySelector("#counter-button"); | |
title.textContent = "TypeScript"; | |
const counter = new Counter(); | |
button.addEventListener( | |
"click", | |
() => { | |
counter.increment(); | |
count.textContent = String(counter.getValue()); | |
}, | |
false | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.container, | |
.container button { | |
text-align: center; | |
font: 1em sans-serif; | |
} | |
.logo { | |
width: 150px; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment