How to empty an input type="number" in js?

1

How can I empty an input type="number" in javascript. Can you use the document.innerHTML = number; or how is it done?

    
asked by user733419 19.02.2018 в 19:42
source

2 answers

0

You have to use value

document.getElementById("elIdDelInput").value = "";

greetings

    
answered by 19.02.2018 в 19:53
0

A quick and short way would be this ... assign an ID to your input:

<input type="number" id="input_vaciar" value="12312313"/>

And then you can empty it like this:

$('#input_vaciar').val('');

And if you need to save some specific data after doing an action, it would be like this:

$('#input_vaciar').val(new_val);

(where new_val can be a data that you set so raw or can be a variable that contains a numeric value as a result of X action)

    
answered by 19.02.2018 в 20:09