Last active
May 30, 2024 20:31
-
-
Save kyletolle/a9c4e3eb0fc95a140f330dcbac1195c6 to your computer and use it in GitHub Desktop.
Some simple HTML pages to share with Maisie
This file contains hidden or 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> | |
<head> | |
<title>Change Text Example</title> | |
</head> | |
<body> | |
<h1>Change Text with JavaScript</h1> | |
<p id="myParagraph">This is the original text.</p> | |
<button onclick="changeText()">Change Text</button> | |
<button onclick="fooblap()">Button without a Function!</button> | |
<script> | |
function changeText() { | |
document.getElementById("myParagraph").innerText = "The text has been changed!"; | |
} | |
</script> | |
</body> | |
</html> |
This file contains hidden or 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> | |
<head> | |
<title>My First Web Page</title> | |
</head> | |
<body> | |
<h1>Welcome to My Web Page</h1> | |
<p>This is a paragraph of text.</p> | |
<input type="number" id="myNumber" value="0"> | |
<button onclick="doubleTheNumber()">Double the Number!</button> | |
<script> | |
function doubleTheNumber() { | |
const numberElement = document.getElementById("myNumber") | |
const userNumber = numberElement.value; | |
const doubledValue = userNumber * 2; | |
alert(`The double of ${userNumber} is ${doubledValue}`); | |
} | |
</script> | |
</body> | |
</html> |
This file contains hidden or 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> | |
<head> | |
<title>Simple Calculator</title> | |
</head> | |
<body> | |
<h1>Simple Calculator</h1> | |
<input id="num1" placeholder="Enter first number"> | |
<input type="number" id="num2" placeholder="Enter second number"> | |
<button onclick="calculate()">Calculate</button> | |
<p id="result"></p> | |
<script> | |
function calculate() { | |
let num1 = parseFloat(document.getElementById("num1").value); | |
num1 = isNaN(num1) ? 0 : num1; | |
num1 = Math.round(num1); | |
let num2 = parseFloat(document.getElementById("num2").value); | |
num2 = isNaN(num2) ? 0 : num2; | |
num2 = Math.round(num2); | |
const result = num1 + num2; | |
document.getElementById("result").innerText = "Result " + result; | |
} | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment