Created
October 27, 2012 11:30
-
-
Save Neolot/3964353 to your computer and use it in GitHub Desktop.
JQUERY Автоочистка поля при фокусе
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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