How to clear a textbox in javascript?

You can use the onfocus attribute in JavaScript to clear a textbox or an input box when somebody sets focus on the field. If you are using jQuery, then use the . focus() method to clear the field.

How do you clear a text box in HTML?

To clear all the input in an HTML form, use the tag with the type attribute as reset.

How do you write a clear function in JavaScript?