4th Nov 2022, 8:52 AM
Varin
Varin - avatar
1 Antwort
+ 4
Varin , This is the correct code that you want. const distance = document.getElementById("distance") const time = document.getElementById("Time") const caculate = document.getElementById('result') const distance_caculate = document.getElementById("distance-caculate") const speed = document.getElementById('speed') const time_caculate = document.getElementById('time-caculate') let d, s window.onload = () => { caculate.onclick = function(){ d = parseInt(distance.value) s = parseInt(time.value) console.log(d/s) } time_caculate.addEventListener("click", e => { d = parseInt(distance.value) s = parseInt(time.value) console.log(d/s) }) }
4th Nov 2022, 9:19 AM
SoloProg
SoloProg - avatar