I am trying to collect data from an input and there is no way. Let's see if you can help me because I'm stuck...
<body>
<div id="monedero" class="flex-container">
<form>
<input type="text" name="campoTexto" maxlength="3" size="3"
title="Introduce el número de monedas" id="campoTexto">
</form>
<button type="button" id="boton">Insertar</button>
</div>
<script src="tragaperras.js"></script>
</body>
var campoTextoValue = document.getElementsById("campoTexto");
function miFuncion(){
console.log(campoTextoValue);
}
document.getElementById("boton").addEventListener("click", miFuncion);
The console message collects the execution of the function, but it comes out empty, it does not collect the data that I enter in the field in the text field.
You need the function to get the value of the input, in addition, you have an "s" left over, it would stay:
The way you have it right now you are fetching the element itself, i.e. the entire input tag.