Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // This script is an update of http://www.perfectline.co/2009/10/change-input-field-placeholder-with-jquery/
- // If you don't need input[type=password] support use http://pastebin.com/w7PhFQdu
- $(document).ready( function() {
- $(".placeholder").each( function( ) {
- var elem = $(this);
- var text = elem.attr('rel');
- if( elem.attr('type') === 'password' )
- elem.type = 'password';
- if ( elem.val() === '' ) {
- elem.val( text );
- if( elem.type === 'password' )
- elem.attr('type', 'text' );
- }
- elem.focus( function() {
- if ( elem.val() === text ) {
- elem.val('');
- if( elem.type === 'password' )
- elem.attr('type', 'password');
- }
- });
- elem.blur( function() {
- if ( elem.val() === '' ) {
- elem.val( text );
- if( elem.type === 'password' )
- elem.attr('type', 'text');
- }
- });
- var form = elem.parents('form:first');
- form.submit( function() {
- if (elem.val() === text)
- elem.val("");
- });
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement