awj
0
Q:

clear input field javascript

<!--Clearing input field in javascript-->
<input type="text" value="Blabla" id="myInput">
<button onclick="clear()">Clear input field</button>

<script>
  function clear(){
  		document.getElementById('myInput').value = ''
  }
</script>
3
Clear input field on focus
<!-- When the input field gets focus, replace its current value with an empty string -->
<input type="text" onfocus="this.value=''" value="The text">
0

New to Communities?

Join the community