From 926c7719170d027066d762065100c51579dfe522 Mon Sep 17 00:00:00 2001 From: Margit Tennosaar <46651865+margittennosaar@users.noreply.github.com> Date: Tue, 31 Jan 2023 12:26:14 +0200 Subject: [PATCH] addEventListener --- session_3/index.html | 2 +- session_3/main.js | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/session_3/index.html b/session_3/index.html index 1fc0f23..b81c6d6 100644 --- a/session_3/index.html +++ b/session_3/index.html @@ -32,7 +32,7 @@

Gasoline price

- +

diff --git a/session_3/main.js b/session_3/main.js index 9dbd211..fd19942 100644 --- a/session_3/main.js +++ b/session_3/main.js @@ -1,3 +1,5 @@ +const calcButton = document.querySelector('#calc'); + const calcGasoline = (e) => { e.preventDefault(); const price = Number(document.getElementById('price').value); @@ -18,6 +20,8 @@ const calcGasoline = (e) => { document.querySelector('#answer').textContent = 'something'; }; +calcButton.addEventListener('click', calcGasoline); + const tempConventer = (id, value) => { const val = parseFloat(value);