I have the following code so that when a users selects an input box the value will disappear, but the default value will then be re-inserted once a user clicks off it.
$(function() {
var defaultText = '';
$('input[id=input]').focus(function() {
defaultText = $(this).val();
$(this).val('');
});
$('input[id=input]').blur(function() {
$(this).val(defaultText);
});
});
However, that's not exactly how I want it. If a user inserts text I don't want the default text to then override what the user has put. I'm also fairly new to jQuery so any help would be greatly appreciated.
defaultText
... onfocus
it is changing thedefaultText
value to whatever the current value of the input is. – Likeminded