How to clear HTML input field value in JavaScript

1 Answer

0 votes
<input type="text" value="abc" id="iid"/>
<button id="btn">Clear</button>
const inputText = document.getElementById("iid");
const btn = document.getElementById("btn");

btn.addEventListener('click',()=>{
    inputText.value = " ";
})
  
    
    
    
/*
run:

    
*/

 



answered Jun 17, 2021 by avibootz
...