Return to Snippet

Revision: 57011
at May 4, 2012 00:53 by gdesjardins


Initial Code
// make HTML5 placeholders work in non supportive browsers
	$("input[placeholder]").each(function(){
		if($(this).val()==""){
			// $(this).addClass('hasplaceholder');
			$(this).val($(this).attr("placeholder"));
			$(this).focus(function(){
				if($(this).val()==$(this).attr("placeholder")) $(this).val("");
				// $(this).removeClass('hasplaceholder');
			});
			$(this).blur(function(){
				if($(this).val()==""){
					// $(this).addClass('hasplaceholder');
					$(this).val($(this).attr("placeholder"));
				}
			});
		}
	});

	$('form').submit(function(evt){
		$('input[placeholder]').each(function(){
			if($(this).attr("placeholder") == $(this).val()) {$(this).val('');}
		});
	});
});

Initial URL


Initial Description
make HTML5 placeholders work in non supportive browsers

Initial Title
make HTML5 placeholders work in non supportive browsers

Initial Tags


Initial Language
JavaScript