Skip to content

Instantly share code, notes, and snippets.

@dotmh
Created October 12, 2011 15:43
Show Gist options
  • Save dotmh/1281565 to your computer and use it in GitHub Desktop.
Save dotmh/1281565 to your computer and use it in GitHub Desktop.
A quick Jquery fallback for form placement
(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