Skip to content

Instantly share code, notes, and snippets.

@fdaciuk
Created August 20, 2013 18:22
Show Gist options
  • Save fdaciuk/6285202 to your computer and use it in GitHub Desktop.
Save fdaciuk/6285202 to your computer and use it in GitHub Desktop.
Polyfill para placeholder
$formLogin = $( 'form.form-login' );
$formLogin.find( 'label' ).addClass( 'js' );
$formLogin.find( 'input[type=text], input[type=password]' ).each(function(){
// Verifica se os campos estão preenchidos (autocompletar do browser)
if( $( this ).val() !== '' ) {
$( this ).prev( 'label' ).animate({'font-size' : 0}, 200);
}
$( this ).focus(function(){
$( this ).animate({boxShadow : '0 0 13px #fc0'}, 300)
.prev( 'label' ).animate({'opacity' : '0.5'}, 200);
})
$( this ).blur(function(){
$( this ).animate({boxShadow : '0 0 0 #fc0'}, 300)
.prev( 'label' ).animate({'opacity' : '1'}, 200);
if( $( this ).val() == '' ){
$( this ).prev( 'label' ).animate({'font-size' : '11px'}, 200);
}
})
$( this ).keypress(function(){
$( this ).prev( 'label' ).animate({'font-size' : 0}, 200);
})
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment