Files
JavaScript-from-Beginner-to…/Chapter 9/Code Samples/ch9-new-element.html
T
2021-11-25 14:40:42 +01:00

12 lines
305 B
HTML
Executable File

<html>
<body>
<script>
function addRandomNumber(){
let el = document.createElement("p");
el.innerText = Math.floor(Math.random() * 100);
document.body.appendChild(el);
}
</script>
<button onclick="addRandomNumber()">Add a number</button>
</body>
</html>