jquery function val() is not equivalent to “$(this).value=”?

You want:

this.value=""; // straight JS, no jQuery

or

$(this).val(''); // jQuery

With $(this).value="" you’re assigning an empty string as the value property of the jQuery object that wraps this — not the value of this itself.

Leave a Comment