File tree Expand file tree Collapse file tree 1 file changed +12
-10
lines changed
慕课网教程案例/jQuery入门教程/jQuery表单事件 Expand file tree Collapse file tree 1 file changed +12
-10
lines changed Original file line number Diff line number Diff line change 7
7
< style >
8
8
.left div ,
9
9
.right div {
10
- width : 500px ;
11
- height : 50px ;
10
+ width : 100% ;
12
11
padding : 5px ;
13
12
margin : 5px ;
14
13
float : left;
@@ -42,22 +41,25 @@ <h2>input、textarea与select</h2>
42
41
< textarea class ="target2 " rows ="3 " cols ="20 "> 多行的文本输入控件</ textarea >
43
42
</ div >
44
43
</ div >
45
-
44
+ 输出结果:
45
+ < div id ="result "> </ div >
46
46
< script type ="text/javascript ">
47
+
47
48
//监听input值的改变
48
49
$ ( '.target1' ) . change ( function ( e ) {
49
- alert ( e . target . value )
50
+ $ ( "#result" ) . html ( e . target . value )
50
51
} ) ;
52
+
51
53
//监听select:
52
- $ ( ".target2" ) . focusin ( function ( e ) {
53
- alert ( e . target . value )
54
+ $ ( ".target2" ) . change ( function ( e ) {
55
+ $ ( "#result" ) . html ( e . target . value )
54
56
} )
55
- //监听textarea:
56
- $ ( ".target3" ) . focusin ( function ( e ) {
57
- alert ( e . target . value )
57
+
58
+ //监听textarea:
59
+ $ ( ".target3" ) . change ( function ( e ) {
60
+ $ ( "#result" ) . html ( e . target . value )
58
61
} )
59
62
</ script >
60
-
61
63
</ body >
62
64
63
65
</ html >
You can’t perform that action at this time.
0 commit comments