Revision: 19982
Updated Code
at November 4, 2009 11:24 by smoothdzion
Updated Code
$(function(){ $('input[type="text"]').each(function(){ if(this.value==''){this.value='Enter Value'} }); $('input[type="text"]').focus(function(){ if(this.value=='Enter Value'){this.value=''} }); $('input[type="text"]').blur(function(){ if(this.value==''){this.value='Enter Value'} }); });
Revision: 19981
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at November 4, 2009 11:22 by smoothdzion
Initial Code
$(function(){ $('input[type="text"]').each(function(){ if(this.value==''){this.value='Enter Value'} }); $('input[type="text"]').focus(function(){ if(this.value=='Enter Value'){this.value=''} }); $('input[type="text"]').blur(function(){ if(this.value==''){this.value='Enter Value'} }); });
Initial URL
Initial Description
First value takes empty input values and adds 'Enter Value'.<br> Second snippet removes 'Enter Value' when input is focused.<br> Third snippet re-adds 'Enter Value' if the value is left blank.
Initial Title
jQuery - Add/Focus/Blur Input Value
Initial Tags
javascript, textmate, jquery
Initial Language
jQuery