I have the following code:
$('#name1').focus(function() {
if ($(this).val() == 'start value') {
console.log($(this).val()); // this prints "start value"
$(this).val() == ''
}
What I am trying to do is when a user focuses on the text input #name1, the field’s value will disappear. However, the above does nothing, and the text value stays the same. Why is this occurring and what do I need to change?
You must write assigning value in parentheses like this
$(this).val("");