From dd7c626a187dc3baca6b99af966d19d92c5a6360 Mon Sep 17 00:00:00 2001 From: Mathias Bynens Date: Fri, 2 Jul 2010 13:10:10 +0200 Subject: [PATCH] =?UTF-8?q?Use=20focus()=20and=20blur()=20instead=20of=20f?= =?UTF-8?q?ocusin()=20and=20focusout()=20to=20ensure=20compatibility=20wit?= =?UTF-8?q?h=20previous=20jQuery=20versions.=20In=20this=20case,=20there?= =?UTF-8?q?=E2=80=99s=20no=20reason=20to=20choose=20focusin()=20over=20foc?= =?UTF-8?q?us()=20anyway.=20Fixes=20issue=20#3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 6 +++--- jquery.placeholder.js | 6 +++--- jquery.placeholder.min.js | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 4747836..a1bf501 100644 --- a/README.md +++ b/README.md @@ -25,12 +25,12 @@ This plugin was based on a code snippet by [Paul Irish](http://paulirish.com/), The plugin automatically adds class="placeholder" to the elements who are currently showing their placeholder text. You can use this to style placeholder text differently: input { color: #000; } - .placeholder { color: #666; } + .placeholder { color: #aaa; } ## Notes -The plugin automatically checks if the browser supports the HTML5 placeholder attribute for inputs natively. If this is the case, the plugin won’t do anything. -The plugin will ignore password inputs. +* The plugin automatically checks if the browser supports the HTML5 placeholder attribute for inputs natively. If this is the case, the plugin won’t do anything. +* The plugin will ignore password inputs. ## Credits diff --git a/jquery.placeholder.js b/jquery.placeholder.js index a2c2602..c5fd724 100644 --- a/jquery.placeholder.js +++ b/jquery.placeholder.js @@ -1,5 +1,5 @@ /*! - * HTML5 Placeholder jQuery Plugin v1.0 + * HTML5 Placeholder jQuery Plugin v1.1 * @link http://github.com/mathiasbynens/Placeholder-jQuery-Plugin * @author Mathias Bynens */ @@ -37,11 +37,11 @@ return; }; setPlaceholder($input); - $input.focusin(function() { + $input.focus(function() { if ($input.val() === $input.attr('placeholder')) { $input.val('').removeClass('placeholder'); }; - }).focusout(function() { + }).blur(function() { setPlaceholder($input); }); }); diff --git a/jquery.placeholder.min.js b/jquery.placeholder.min.js index a0de164..1a019df 100644 --- a/jquery.placeholder.min.js +++ b/jquery.placeholder.min.js @@ -1,6 +1,6 @@ /*! - * HTML5 Placeholder jQuery Plugin v1.0 + * HTML5 Placeholder jQuery Plugin v1.1 * @link http://github.com/mathiasbynens/Placeholder-jQuery-Plugin * @author Mathias Bynens */ -(function(a){a.fn.placeholder=function(){if(this[0]&&'placeholder' in document.createElement('input')){return this}function b(c){if(c.val()===''||c.val()===c.attr('placeholder')){c.addClass('placeholder').val(c.attr('placeholder'))}else{c.removeClass('placeholder')}}a('form:has(input[placeholder])').submit(function(){a('.placeholder',this).val('')});a(window).unload(function(){a('.placeholder').val('')});return this.each(function(){var c=a(this);if(c.is(':password')||!c.is(':input')){return}b(c);c.focusin(function(){if(c.val()===c.attr('placeholder')){c.val('').removeClass('placeholder')}}).focusout(function(){b(c)})})}})(jQuery); \ No newline at end of file +(function(a){a.fn.placeholder=function(){if(this[0]&&'placeholder' in document.createElement('input')){return this}function b(c){if(c.val()===''||c.val()===c.attr('placeholder')){c.addClass('placeholder').val(c.attr('placeholder'))}else{c.removeClass('placeholder')}}a('form:has(input[placeholder])').submit(function(){a('.placeholder',this).val('')});a(window).unload(function(){a('.placeholder').val('')});return this.each(function(){var c=a(this);if(c.is(':password')||!c.is(':input')){return}b(c);c.focus(function(){if(c.val()===c.attr('placeholder')){c.val('').removeClass('placeholder')}}).blur(function(){b(c)})})}})(jQuery); \ No newline at end of file