I am having a html text field which can hide.
When hiding I want clear the text field.
I used this and it doesn't work.
$('#id').val("");
And I tried $('#id').text("");
as well.
It removed the whole text field.
This is correct:
$('#id').val('');
However, your part 2 is interesting.
$('#id').text("");
That shouldn't create the behavior you're describing. I expect that you're referencing the parent object, not the <input>
directly.