Created
September 26, 2021 05:52
-
-
Save iwo-strzebonski/8b67ff97efed2972bd89847170b1bdb9 to your computer and use it in GitHub Desktop.
Prosta strona dzieląca liczby na ujemne i dodatnie
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
<!DOCTYPE html> | |
<html lang='pl'> | |
<head> | |
<meta charset='utf-8'> | |
<meta name='viewport' content='width=device-width'> | |
<title>Sprawdzian</title> | |
<style> | |
html, | |
body { | |
width: 100vw; | |
height: 100vh; | |
margin: 0; | |
padding: 0; | |
} | |
body { | |
display: inline-flex; | |
justify-content: space-evenly; | |
} | |
div { | |
text-align: center; | |
box-sizing: border-box; | |
border: 1px solid black; | |
margin: 1vh 1vw; | |
width: 32vw; | |
height: 98vh; | |
padding: 4px; | |
} | |
</style> | |
</head> | |
<body> | |
<div id='negative'></div> | |
<div id='input'> | |
<input type='number' id='number-input' /> | |
<button id='number-btn'>Przypisz liczbę</button> | |
<script> | |
document.getElementById('number-btn').onclick = () => { | |
let number = document.getElementById('number-input').value | |
let span = document.createElement('span') | |
if (number == 0) alert('Liczba "0" nie jest ani dodatnia, ani ujemna!') | |
else { | |
span.innerText = number | |
document.getElementById(number > 0 ? 'positive' : 'negative').appendChild(span) | |
} | |
} | |
</script> | |
</div> | |
<div id='positive'></div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment