Posted By

cryothic on 07/29/10


Tagged

replace label textBox


Versions (?)

Who likes this?

3 people have marked this snippet as a favorite

damarev
jackkeller
wattsupnow


Textbox inside-label replace


 / Published in: jQuery
 

Replaces the pre-defined text of a textbox (e.g. the purpose of the textbox) when the textbox gets focussed, and resets the text if it blurs when empty

  1. <input type="text" value="Name" rel="Name" class="replace" />
  2.  
  3. $(".replace")
  4. .focus(function(){
  5. if ($(this).val() === $(this).attr("rel")) {
  6. $(this).val("").css("color", "#000000");
  7. }
  8. })
  9. .blur(function(){
  10. if ($(this).val() === "") {
  11. $(this).val($(this).attr("rel")).css("color", "#5e6a72");
  12. }
  13. });

Report this snippet  

You need to login to post a comment.