createPlaceholder 函数
function createPlaceholder(id,text,top,left){ top = top || 0; left = left || 0; var obj = $('#' + id)[0], parent = obj.parentNode, clickEvent = function(){ $(this).hide(); var target = this.nextSibling; if( target.nodeName=='#text' ) { target = target.nextSibling; } target.focus(); }, blurEvent = function(){ var value = $.trim(this.value); if( value=='' ) { $(div).show(); } }, focusEvent = function(){ $(div).hide(); }; var div = document.createElement('div'); div.innerHTML = text; $(div).css({position: 'absolute', top: top, left: left, color: "red"}); parent.insertBefore(div,obj); $(div).click(clickEvent); $(obj).blur(blurEvent); $(obj).focus(focusEvent); }