/ Published in: jQuery
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
$('input[type=text]').each(function(){ var target = $(this); if(title = target.attr('title')){ if(target.val().length === 0){ target.val(target.attr('title')); } target.bind('blur', function(){ if(target.val().length === 0){ target.val(target.attr('title')); } }); target.bind('focus', function(){ if(target.val() === target.attr('title')){ target.val(''); } }); } });