/ Published in: jQuery

First value takes empty input values and adds 'Enter Value'.
Second snippet removes 'Enter Value' when input is focused.
Third snippet re-adds 'Enter Value' if the value is left blank.
Second snippet removes 'Enter Value' when input is focused.
Third snippet re-adds 'Enter Value' if the value is left blank.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
$(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'} }); });
Comments
