All pastes #779113 Raw Edit

Anonymous

public text v1 · immutable
·published 2007-11-18 05:50 UTC
rendered paste body
function checkText( input, event ) {
	switch ($(input).attr("id")) {
		case 'title':
			default_val= 'Title';
			break;
		case 'content':
			default_val= 'Content';
			break;
		case 'tags':
			default_val= 'Tags- comma separated';
			break;
	}
	
	switch (event) {
		case 'focus':
			if ( $(input).val() == default_val ) {
				$(input).val('');
			}
			break;
		case 'blur':
			if ( $(input).val() == '' ) {
				$(input).val(default_val);
			}
			break;
	}
}

function focusText( input ) {
	checkText( this, 'focus' );
}

function blurText( input ) {
	checkText( this, 'blur' );
}

$(document).ready(function () {
	$('#title, #content, #tags').focus(focusText).blur(blurText);
})