Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

how to reset input field in javascript

document.querySelector('#counter').value = '';
Comment

clear input field javascript

<form id="myForm">
  First name: <input type="text" name="fname" value="Demo"><br>
  Last name: <input type="text" name="lname"><br><br>
    <input type="file" name="Photo" class=" custom-file-input" id="photo">
  <input type="button" onclick="myFunction()" value="Reset form">
</form>
     
<script>
function myFunction() {
    document.getElementById("myForm").reset();
}
</script>
 Run code snippetHide results
Comment

PREVIOUS NEXT
Code Example
Javascript :: javascript import class from another file 
Javascript :: how to use jquery timepicker 
Javascript :: clear interval e.close is not a function 
Javascript :: passing state in link react 
Javascript :: parent of heap node 
Javascript :: disable key enter react-hook-form 
Javascript :: js print all prime numbers 
Javascript :: ternary operator in angular 
Javascript :: restrict the user from going to signup or login page if the user is already logged in firebase auth 
Javascript :: how to change the text using jquery on click 
Javascript :: remove url from string javascript 
Javascript :: conditionally changing styled components based on props 
Javascript :: javascript break with for Loop 
Javascript :: unix timestamp to date javascript yyyy-mm-dd 
Javascript :: how to remove an object from jsonobject in java 
Javascript :: embed example discord.js 
Javascript :: how to update the react version in next js app 
Javascript :: jquery find div with data attribute value 
Javascript :: js capitalize first letter 
Javascript :: lazy react 
Javascript :: how to convert node list to array in javascript 
Javascript :: user focus on tab javascript 
Javascript :: inner html jquery 
Javascript :: nodejs javascript heap out of memory 
Javascript :: jquery append table row 
Javascript :: js foreach class 
Javascript :: element en html and js 
Javascript :: Javascript form check to see if return or enter was pressed 
Javascript :: readfile nodejs 
Javascript :: statement and expression in js 
ADD CONTENT
Topic
Content
Source link
Name
7+6 =