clear input field value 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>