Skip to content

Instantly share code, notes, and snippets.

@Neolot
Created October 27, 2012 11:30
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Neolot/3964353 to your computer and use it in GitHub Desktop.
Save Neolot/3964353 to your computer and use it in GitHub Desktop.
JQUERY Автоочистка поля при фокусе
(function($) {
$(function() {
$('#selector').each(function(){
var text = $(this).val();
$(this)
.focusin(function(){
$(this).addClass('focus');
if ($(this).val() == text) $(this).val('');
})
.focusout(function(){
if ($(this).val() == '') $(this).val(text);
$(this).removeClass('focus');
});
});
})
})(jQuery)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment