Why is this method not working when I try to clear the text field?
You can just change the reference of input value, as below
Clear