Skip to content

Commit

Permalink
addEventListener
Browse files Browse the repository at this point in the history
  • Loading branch information
margittennosaar committed Jan 31, 2023
1 parent 5a1a1f2 commit 926c771
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion session_3/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ <h2>Gasoline price</h2>
<label for="money">Money</label>
<input type="number" id="money" />
</div>
<button onclick="calcGasoline()">Calculate</button>
<button id="calc">Calculate</button>
</form>

<p id="answer"></p>
Expand Down
4 changes: 4 additions & 0 deletions session_3/main.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const calcButton = document.querySelector('#calc');

const calcGasoline = (e) => {
e.preventDefault();
const price = Number(document.getElementById('price').value);
Expand All @@ -18,6 +20,8 @@ const calcGasoline = (e) => {
document.querySelector('#answer').textContent = 'something';
};

calcButton.addEventListener('click', calcGasoline);

const tempConventer = (id, value) => {
const val = parseFloat(value);

Expand Down

0 comments on commit 926c771

Please sign in to comment.