My code doesn’t run and I want the value to be cleared when you click on another
what am I doing wrong?
var placeholderText = $('input').val();
$(placeholderText).focus(function() {
$(this).attr('value', "");
});
$(placeholderText).blur(function() {
$(this).attr('value', phTextVal);
});
You’re using ‘placeholderText’ as a selector, which won’t select anything. Use
$('input').focus(...and$('input').blur(...instead.UPDATE
If you want to store the existing value, and then replace it, then store it as
.data()in the<input>element itself:http://jsfiddle.net/mblase75/AL2vS/12/
Or possibly: