Skip to content

Instantly share code, notes, and snippets.

@paulodiovani
Forked from manfromanotherland/gist:2228169
Created September 4, 2012 19:04

Revisions

  1. @manfromanotherland manfromanotherland revised this gist Mar 28, 2012. 2 changed files with 21 additions and 22 deletions.
    21 changes: 21 additions & 0 deletions gistfile1.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@
    // Released under MIT license: http://www.opensource.org/licenses/mit-license.php
    $('[placeholder]').focus(function() {
    var input = $(this);
    if (input.val() == input.attr('placeholder')) {
    input.val('');
    input.removeClass('placeholder');
    }
    }).blur(function() {
    var input = $(this);
    if (input.val() == '' || input.val() == input.attr('placeholder')) {
    input.addClass('placeholder');
    input.val(input.attr('placeholder'));
    }
    }).blur().parents('form').submit(function() {
    $(this).find('[placeholder]').each(function() {
    var input = $(this);
    if (input.val() == input.attr('placeholder')) {
    input.val('');
    }
    })
    });
    22 changes: 0 additions & 22 deletions jQuery HTML5 placeholder fix.js
    Original file line number Diff line number Diff line change
    @@ -1,22 +0,0 @@
    // Released under MIT license: http://www.opensource.org/licenses/mit-license.php

    $('[placeholder]').focus(function() {
    var input = $(this);
    if (input.val() == input.attr('placeholder')) {
    input.val('');
    input.removeClass('placeholder');
    }
    }).blur(function() {
    var input = $(this);
    if (input.val() == '' || input.val() == input.attr('placeholder')) {
    input.addClass('placeholder');
    input.val(input.attr('placeholder'));
    }
    }).blur().parents('form').submit(function() {
    $(this).find('[placeholder]').each(function() {
    var input = $(this);
    if (input.val() == input.attr('placeholder')) {
    input.val('');
    }
    })
    });
  2. @hagenburger hagenburger revised this gist Oct 21, 2011. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions jQuery HTML5 placeholder fix.js
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,5 @@
    // Released under MIT license: http://www.opensource.org/licenses/mit-license.php

    $('[placeholder]').focus(function() {
    var input = $(this);
    if (input.val() == input.attr('placeholder')) {
  3. @hagenburger hagenburger revised this gist Sep 29, 2010. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion jQuery HTML5 placeholder fix.js
    Original file line number Diff line number Diff line change
    @@ -6,7 +6,7 @@ $('[placeholder]').focus(function() {
    }
    }).blur(function() {
    var input = $(this);
    if (input.val() == '') {
    if (input.val() == '' || input.val() == input.attr('placeholder')) {
    input.addClass('placeholder');
    input.val(input.attr('placeholder'));
    }
  4. @hagenburger hagenburger renamed this gist Apr 26, 2010. 1 changed file with 0 additions and 0 deletions.
  5. @hagenburger hagenburger created this gist Apr 26, 2010.
    20 changes: 20 additions & 0 deletions jQuery HTML5 placeholder fix
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    $('[placeholder]').focus(function() {
    var input = $(this);
    if (input.val() == input.attr('placeholder')) {
    input.val('');
    input.removeClass('placeholder');
    }
    }).blur(function() {
    var input = $(this);
    if (input.val() == '') {
    input.addClass('placeholder');
    input.val(input.attr('placeholder'));
    }
    }).blur().parents('form').submit(function() {
    $(this).find('[placeholder]').each(function() {
    var input = $(this);
    if (input.val() == input.attr('placeholder')) {
    input.val('');
    }
    })
    });