File tree Expand file tree Collapse file tree 4 files changed +39
-17
lines changed Expand file tree Collapse file tree 4 files changed +39
-17
lines changed Original file line number Diff line number Diff line change 27
27
height : 100px ;
28
28
}
29
29
</ style >
30
- < script src ="http://libs.baidu .com/jquery/1.9.1/jquery.js "> </ script >
30
+ < script src ="http://lib.sinaapp .com/js/ jquery/1.9.1/jquery-1.9.1.min .js "> </ script >
31
31
</ head >
32
32
33
33
< body >
34
34
< h2 > input与textarea</ h2 >
35
35
< div class ="left ">
36
+ < h4 > 测试一</ h4 >
36
37
< div class ="aaron ">
37
- 用鼠标选中文字 :input
38
- < input type ="text " value ="Hello 慕课网 " />
38
+ 选中文字 :input
39
+ < input type ="text " value ="慕课网 " />
39
40
</ div >
41
+ < button id ="bt1 "> 触发input元素的select事件</ button >
42
+
43
+ < h4 > 测试二</ h4 >
40
44
< div class ="aaron ">
41
45
textarea:
42
46
< textarea rows ="3 " cols ="20 "> 用鼠标选中文字</ textarea >
43
47
</ div >
44
48
</ div >
49
+
45
50
< script type ="text/javascript ">
51
+
46
52
//监听input元素中value的选中
47
- $ ( 'input' ) . select ( function ( e ) {
48
- alert ( e . target . value ) ;
49
- } ) ;
53
+ //触发元素的select事件
54
+ $ ( "input" ) . select ( function ( e ) {
55
+ alert ( e . target . value )
56
+ } )
57
+ $ ( "#bt1" ) . click ( function ( ) {
58
+ $ ( "input" ) . select ( ) ;
59
+ } )
60
+
50
61
51
62
//监听textarea元素中value的选中
52
63
$ ( 'textarea' ) . select ( function ( e ) {
Original file line number Diff line number Diff line change 27
27
height : 100px ;
28
28
}
29
29
</ style >
30
- < script src ="http://libs.baidu .com/jquery/1.9.1/jquery.js "> </ script >
30
+ < script src ="http://lib.sinaapp .com/js/ jquery/1.9.1/jquery-1.9.1.min .js "> </ script >
31
31
</ head >
32
32
33
33
< body >
34
34
< h2 > submit</ h2 >
35
35
< div class ="left ">
36
36
< div class ="aaron ">
37
- < form id ="target1 " action ="test .html ">
38
- 回车键或者点击提交表单:
37
+ < form id ="target2 " action ="destination .html ">
38
+ 回车键或者点击提交表单,禁止浏览器默认跳转:
39
39
< input type ="text " value ="输入新的值 " />
40
40
< input type ="submit " value ="Go " />
41
41
</ form >
42
42
</ div >
43
43
< div class ="aaron ">
44
- < form id ="target2 " action ="destination .html ">
45
- 回车键或者点击提交表单,禁止浏览器默认跳转:
44
+ < form id ="target1 " action ="test .html ">
45
+ 回车键或者点击提交表单:
46
46
< input type ="text " value ="输入新的值 " />
47
47
< input type ="submit " value ="Go " />
48
48
</ form >
Original file line number Diff line number Diff line change 25
25
display : block;
26
26
}
27
27
</ style >
28
- < script src ="http://libs.baidu .com/jquery/1.9.1/jquery.js "> </ script >
28
+ < script src ="http://lib.sinaapp .com/js/ jquery/1.9.1/jquery-1.9.1.min .js "> </ script >
29
29
</ head >
30
30
31
31
< body >
Original file line number Diff line number Diff line change 23
23
color : red;
24
24
}
25
25
</ style >
26
- < script src ="http://libs.baidu .com/jquery/1.9.1/jquery.js "> </ script >
26
+ < script src ="http://lib.sinaapp .com/js/ jquery/1.9.1/jquery-1.9.1.min .js "> </ script >
27
27
</ head >
28
28
29
29
< body >
30
- < h2 > keydown</ h2 >
30
+ < h2 > keydown()与keyup()事件 </ h2 >
31
31
< div class ="left ">
32
+ < h4 > 测试一</ h4 >
32
33
< div class ="aaron "> 监听keydown输入:
33
34
< input class ="target1 " type ="text " value ="" /> < br />
34
- 显示输入的值:< em > 1</ em >
35
+ 按下显示输入的值:< em > </ em >
36
+ </ div >
37
+ < h4 > 测试二</ h4 >
38
+ < div class ="aaron "> 监听keyup输入:
39
+ < input class ="target2 " type ="text " value ="" /> < br />
40
+ 松手显示输入的值:< em > </ em >
35
41
</ div >
36
-
37
42
</ div >
38
43
39
44
< script type ="text/javascript ">
40
45
//监听键盘按键
41
46
//获取输入的值
42
47
$ ( '.target1' ) . keydown ( function ( e ) {
43
- $ ( "em" ) . text ( e . target . value )
48
+ $ ( "em:first" ) . text ( e . target . value )
49
+ } ) ;
50
+
51
+ //监听键盘按键
52
+ //获取输入的值
53
+ $ ( '.target2' ) . keyup ( function ( e ) {
54
+ $ ( "em:last" ) . text ( e . target . value )
44
55
} ) ;
45
56
46
57
</ script >
You can’t perform that action at this time.
0 commit comments