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...
But reset is use for full form or input what if you only want to use for certain field
That’s a good point! In that case what you demonstrated would be the way to go 😄
There are many ways but I written a beginner friendly
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
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...
But reset is use for full form or input what if you only want to use for certain field
That’s a good point! In that case what you demonstrated would be the way to go 😄
There are many ways but I written a beginner friendly