// JavaScript Document $(function(){ inputVal('input_wrap', 'input'); inputVal('textarea_wrap', 'textarea'); }); //inputWrap function inputVal(wrap, input){ var inputWrap = $('div.' + wrap); inputWrap.each(function(i){ var $span = inputWrap.eq(i).children('span'), $input = inputWrap.eq(i).children(input), eleVal = $input.val(); if(eleVal != ''){ $input.show(); $span.hide(); }; $input.focus(function(){ $span.hide(); }); $input.blur(function(){ var thisVal = $(this).val(); if(thisVal == ''){ $span.show(); }else{ $span.hide(); } }); $span.click(function(){ $(this).hide(); $input.focus(); }); }); }