1
I’m starting to work / learn the DOM
, but I’m having difficulties, because:
const celsius = document.getElementsByName('celsius')[0]
const fahrenheit = document.getElementsByName('fahrenheit')[0]
const buttonClear = document.getElementsByName('limpar')[0]
const buttonSubmit = document.getElementsByName('converter')[0]
//buttonClear.addEventListener('click', limparBox(celsius, fahrenheit))
//buttonClear.onclick = limparBox(celsius, fahrenheit)
function limparBox(input1, input2) {
input1.value = "";
input2.value = "";
}
input[type=text] {
padding: 5px;
border: solid 1px black;
font-style: italic;
font-family: 'Gill Sans', 'Gill Sans MT', Calibri, 'Trebuchet MS', sans-serif;
text-align: center;
border-radius: 2px;
}
button[type=submit] {
background-color: #74f541;
padding: 10px;
font-weight: bold;
border-radius: 3px;
border: solid 1px black;
}
button[type=reset] {
background-color: #f2fa83;
padding: 10px;
font-weight: bold;
border-radius: 3px;
border: solid 1px black;
}
<input type="text" name="celsius" placeholder="Celsius">
<button type="submit" name="converter">Converter para Fahrenheit</button>
<button type="reset" name="limpar">Limpar Textos</button>
<input type="text" name="fahrenheit" placeholder="Fahrenheit">
This one of mine function
if I run in the console
of own browser
the boxes are clean, but when I put it (function
) to execute the click
of a button
is not called, I tried so hard through a callback
how much for a property onclick
.
It is also only possible to access the elements DOM
being in the escopo global
javascript?
What would be the problem of my question please so that in future I have a better performance in scoring?
– user168265