Hello, im Pablo Noel

Designer, Skater, Punk

Clean inputs on focus

Esta entrada fue publicada el:

08June2010

, ,

2 Comentarios

A fast and nice way using Jquery to clean input values on focus, and put the default value back when is empty:

$(".clean").each(function(){
var value = $(this).val();
$(this).focusin(function(){if($(this).val() == value){$(this).val("");};});
$(this).focusout(function(){if($(this).val() == ''){$(this).val(value);};});
});

Just add the class “.clean” to your input tag and voilá.

2 Comentarios para “Clean inputs on focus”

  1. 08 / Jun / 2010 @ 17:49 Tweets that mention Pablo Noel » Clean inputs on focus -- Topsy.com dijo:

    [...] This post was mentioned on Twitter by Pablo Noel, Mr Estupendo. Mr Estupendo said: Como limpiar los valores de una caja de input al tener el foco en ella. Gracias @pablonoel http://icio.us/wdlkpg [...]

  2. 08 / Jun / 2010 @ 20:02 links for 2010-06-08 « newdisco dijo:

    [...] Pablo Noel » Clean inputs on focus Como limpiar los valores de una caja de input al tener el foco en ella con jQuery. Gracias @pablonoel (tags: howto input forms jquery javascript) [...]

Deja tu comentario!