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

Add event listener

parent 0c8d01e9
...@@ -25,9 +25,11 @@ ...@@ -25,9 +25,11 @@
<hr> <hr>
<h2>Otrais Uzdevums</h2> <h2>Otrais Uzdevums</h2>
<p id="otraisUzdevums">Hipotenūzas garums, kur a = 189, b = 256 ir </p> <input type="number" id="a" placeholder="Hipotenūzas A garums">
<button onclick="otraisUzdevums()">Spied lai iegūtu hipotenūzas garumu</button> <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> <hr>
<h2>Trešais Uzdevums</h2> <h2>Trešais Uzdevums</h2>
......
...@@ -27,14 +27,22 @@ function pirmaisUzdevums() { ...@@ -27,14 +27,22 @@ function pirmaisUzdevums() {
dateParagraph.innerText += " plkst. " + datums.getHours() + ":" + datums.getMinutes(); dateParagraph.innerText += " plkst. " + datums.getHours() + ":" + datums.getMinutes();
} }
/*
function otraisUzdevums() { function otraisUzdevums() {
let hypotParagraph = document.getElementById("otraisUzdevums"); let hypotParagraph = document.getElementById("otraisUzdevums");
let a = 189; let a = document.getElementById("a").value;
let b = 256; 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() { function tresaisUzdevums() {
let canvasElement = document.getElementById("tresaisUzdevums"); let canvasElement = document.getElementById("tresaisUzdevums");
...@@ -51,4 +59,4 @@ function tresaisUzdevums() { ...@@ -51,4 +59,4 @@ function tresaisUzdevums() {
$('.ceturtaisUzdevums').click(function(){ $('.ceturtaisUzdevums').click(function(){
$('html, body').animate({scrollTop : 0},800); $('html, body').animate({scrollTop : 0},800);
return false; return false;
}); });
\ No newline at end of file
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