To reset an input field in Javascript, you can use the reset()
method on the form element that the input field belongs to. Here's an example:
294 chars12 lines
In this example, the resetField()
function is called when the "Reset" button is clicked. When this happens, the reset()
method is called on the form element that the input field belongs to, which resets all form elements within the form, including the input field.
gistlibby LogSnag