Commit 0f6deb14 authored by Raitis Ralfs's avatar Raitis Ralfs
Browse files

Add event listener

parent 0c8d01e9
......@@ -25,8 +25,10 @@
<hr>
<h2>Otrais Uzdevums</h2>
<p id="otraisUzdevums">Hipotenūzas garums, kur a = 189, b = 256 ir </p>
<button onclick="otraisUzdevums()">Spied lai iegūtu hipotenūzas garumu</button>
<input type="number" id="a" placeholder="Hipotenūzas A garums">
<input type="number" id="b" placeholder="Hipotenūzas B garums">
<button id="otraisUzdevums">Spied lai iegūtu hipotenūzas garumu</button>
<p>Hipotenūzas garums ir </p> <p id="otraisUzdevumsParagraph"></p>
<hr>
......
......@@ -27,14 +27,22 @@ function pirmaisUzdevums() {
dateParagraph.innerText += " plkst. " + datums.getHours() + ":" + datums.getMinutes();
}
/*
function otraisUzdevums() {
let hypotParagraph = document.getElementById("otraisUzdevums");
let a = 189;
let b = 256;
let a = document.getElementById("a").value;
let b = document.getElementById("b").value;
hypotParagraph.innerText += " " + Math.hypot(a, b).toPrecision(5);
hypotParagraph.innerText = " " + Math.hypot(a, b).toPrecision(5);
}
*/
document.getElementById("otraisUzdevums").addEventListener("click", function(e){
let hypotParagraph = document.getElementById("otraisUzdevumsParagraph");
let a = document.getElementById("a").value;
let b = document.getElementById("b").value;
hypotParagraph.innerText = Math.hypot(a, b).toPrecision(5);
});
function tresaisUzdevums() {
let canvasElement = document.getElementById("tresaisUzdevums");
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment