Skip to content

Instantly share code, notes, and snippets.

@AndreyKozlov1984
Created April 12, 2024 15:45
Show Gist options
  • Save AndreyKozlov1984/a45b98ad0fdf27516c10550c46b7c37f to your computer and use it in GitHub Desktop.
Save AndreyKozlov1984/a45b98ad0fdf27516c10550c46b7c37f to your computer and use it in GitHub Desktop.
Мой первый пример
<h1>Моя первая программа</h1>
Длина
<input id="length" placeholder="Введите длину прямоугольника" style="width: 100px;" />
<br>
<br>
Ширина
<input id="width" placeholder="Введите ширину прямоугольника" style="width: 100px;">
<br>
<br>
<input id="calc" type="button" value="Посчитать площадь" />
<div id="result"></div>
<div id="results"></div>
button = document.querySelector("#calc");
length = document.querySelector("#length");
width = document.querySelector("#width");
result = document.querySelector("#result");
button.addEventListener("click", function () {
area = +length.value * +width.value;
result.innerText = ` Площадь равна ${area}`;
line = document.createElement("div");
line.innerText = `Длина ${width.value} и Ширина ${length.value} дают результат ${area}`;
results.appendChild(line);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment