1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
| // 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();
| });
| });
| }
|
|