How to clear the input in the input box

front-end rookie.
made a todo demo
storage native, without any frame.
after clicking on add, the content in the input box will be inserted into the page, I want to empty it, each time the input is new content, not the last residual. Don"t know how to solve

After

document.getElementById (Id"). Value = "" of the "input button), the value of the input box is cleared. But there are still residual values on the page. Clear the values displayed on the page now.

[picture]
clipboard.png

that is, after I click add, the input box will be cleared until I re-enter it next time. I hope the great gods will answer.

Mar.04,2021

document.getElementById('addId').onclick = function () {
  //to do something   input
  document.getElementById('inputId').value = "";
}

emmm, does not know which framework you use is difficult to answer


after the success of add $("- sharpid"). Val (") ;


first tell me which framework you use? For example, is JavaScript native or jquery?? Angular? Vue? React?


if you are using jquery , you can use $("- sharpyourFormID") [0] .reset ();


add an id= "input1" to the input tag first

when your add is successful:

if you are using native js, you can do this:
document.getElementById ('input1') .value ='

if you use jquery:
$('- sharpinput1'). Val (')


doesn't seem to have the answer I want.


have you solved the problem? I have encountered the same problem recently. I have been unable to solve the vue framework

.
Menu