Feb 26, 2012 - jQuery    Comments Off on Inline Form Labels

Inline Form Labels

jQuery(document).ready(function($) {
	// inline labels for form text fields.
	$('form input[type="text"], form textarea').val(function(index,value){
		$(this).siblings('label').css('display','none');
		return $(this).siblings('label').html();
	});
	$('form input[type="text"], form textarea').focus(function(){
		$(this).val('');
	});
	$('form input[type="text"], form textarea').blur(function(){
		if($(this).val() == ''){
			$(this).val(function(index,value){
				return $(this).siblings('label').html();
			});
		}
	});
});

Comments are closed.