Created
October 12, 2011 15:43
-
-
Save dotmh/1281565 to your computer and use it in GitHub Desktop.
A quick Jquery fallback for form placement
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($){ | |
$.fn.placement = function() { | |
var defaults = {}; | |
this.each(function(){ | |
var el = $(this); | |
var current_id = el.attr('id'); | |
defaults[current_id] = el.val(); | |
el.focus(function(){ | |
if ( el.val() == defaults[current_id] ) { | |
el.val(''); | |
} | |
}); | |
el.blur(function(){ | |
if ( el.val() == '' ) { | |
el.val(defaults[current_id]); | |
} | |
}) | |
}) | |
} | |
})(jQuery) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment