DEV Community

loading...

Discussion on: Amazing Clear Input Using HTML & JS

Collapse
dillonheadley profile image
Dillon Headley

If this was in a form element the x could actually be a button or input with type=“reset” which clears the inputs of a form natively and is accessible by default. No need to build that part yourself in js.

developer.mozilla.org/en-US/docs/W...

Collapse
nikhil27b profile image
Nikhil Bobade Author

But reset is use for full form or input what if you only want to use for certain field

Collapse
dillonheadley profile image
Dillon Headley

That’s a good point! In that case what you demonstrated would be the way to go 😄

Thread Thread
nikhil27b profile image
Nikhil Bobade Author

There are many ways but I written a beginner friendly