1
1
<!doctype html>
2
2
< html lang ="en ">
3
3
< head >
4
- < meta charset ="utf-8 ">
5
- < meta name ="viewport " content ="width=device-width, initial-scale=1 ">
6
- < title > hashtag demo</ title >
7
- < link rel ="stylesheet " href ="http://code.jquery.com/mobile/1.1.1/jquery.mobile-1.1.1.min.css ">
8
- < script src ="http://code.jquery.com/jquery-1.7.2.min.js "> </ script >
9
- < script src ="http://code.jquery.com/mobile/1.1.1/jquery.mobile-1.1.1.min.js "> </ script >
10
- < style >
11
- html , body { padding : 0 ; margin : 0 ; }
12
- html , .ui-mobile , .ui-mobile body {
13
- height : 85px ;
14
- }
15
- .ui-mobile , .ui-mobile .ui-page {
16
- min-height : 85px ;
17
- }
18
- # nav {
19
- font-size : 200% ;
20
- width : 17.1875em ;
21
- margin : 17px auto 0 auto;
22
- }
23
- # nav a {
24
- color : # 777 ;
25
- border : 2px solid # 777 ;
26
- background-color : # ccc ;
27
- padding : 0.2em 0.6em ;
28
- text-decoration : none;
29
- float : left;
30
- margin-right : 0.3em ;
31
- }
32
- # nav a : hover {
33
- color : # 999 ;
34
- border-color : # 999 ;
35
- background : # eee ;
36
- }
37
- # nav a .selected ,
38
- # nav a .selected : hover {
39
- color : # 0a0 ;
40
- border-color : # 0a0 ;
41
- background : # afa ;
42
- }
43
- </ style >
4
+ < meta charset ="utf-8 ">
5
+ < meta name ="viewport " content ="width=device-width, initial-scale=1 ">
6
+ < title > hashtag demo</ title >
7
+ < link rel ="stylesheet " href ="http://code.jquery.com/mobile/1.3.1/jquery.mobile-1.3.1.min.css " />
8
+ < script src ="http://code.jquery.com/jquery-1.10.0.min.js "> </ script >
9
+ < script src ="http://code.jquery.com/mobile/1.3.1/jquery.mobile-1.3.1.min.js "> </ script > < style >
10
+ html , body {
11
+ padding : 0 ; margin : 0 ;
12
+ }
13
+ html , .ui-mobile , .ui-mobile body {
14
+ height : 85px ;
15
+ }
16
+ .ui-mobile , .ui-mobile .ui-page {
17
+ min-height : 85px ;
18
+ }
19
+ # nav {
20
+ font-size : 200% ;
21
+ width : 17.1875em ;
22
+ margin : 17px auto 0 auto;
23
+ }
24
+ # nav a {
25
+ color : # 777 ;
26
+ border : 2px solid # 777 ;
27
+ background-color : # ccc ;
28
+ padding : 0.2em 0.6em ;
29
+ text-decoration : none;
30
+ float : left;
31
+ margin-right : 0.3em ;
32
+ }
33
+ # nav a : hover {
34
+ color : # 999 ;
35
+ border-color : # 999 ;
36
+ background : # eee ;
37
+ }
38
+ # nav a .selected ,
39
+ # nav a .selected : hover {
40
+ color : # 0a0 ;
41
+ border-color : # 0a0 ;
42
+ background : # afa ;
43
+ }
44
+ </ style >
44
45
</ head >
45
46
< body >
46
- < p id ="nav ">
47
- < a href ="#test1 " class ="hashExLink "> test 1</ a >
48
- < a href ="#test2 " class ="hashExLink "> test 2</ a >
49
- < a href ="#test3 " class ="hashExLink "> test 3</ a >
50
- < a href ="#test4 " class ="hashExLink "> test 4</ a >
51
- </ p >
52
- < script >
53
- $ ( function ( ) {
54
- // Bind an event to window.onhashchange that, when the hash changes, gets the
55
- // hash and adds the class "selected" to any matching nav link.
56
- $ ( window ) . hashchange ( function ( ) {
57
- var hash = location . hash ;
47
+ < p id ="nav ">
48
+ < a href ="#test1 " class ="hashExLink "> test 1</ a >
49
+ < a href ="#test2 " class ="hashExLink "> test 2</ a >
50
+ < a href ="#test3 " class ="hashExLink "> test 3</ a >
51
+ < a href ="#test4 " class ="hashExLink "> test 4</ a >
52
+ </ p >
53
+ < script >
54
+ $ ( function ( ) {
55
+ // Bind an event to window.onhashchange that, when the hash changes, gets the
56
+ // hash and adds the class "selected" to any matching nav link.
57
+ $ ( window ) . hashchange ( function ( ) {
58
+ var hash = location . hash ;
58
59
59
- // Set the page title based on the hash.
60
- document . title = ' The hash is ' + ( hash . replace ( / ^ # / , '' ) || ' blank' ) + '.' ;
60
+ // Set the page title based on the hash.
61
+ document . title = " The hash is " + ( hash . replace ( / ^ # / , "" ) || " blank" ) + "." ;
61
62
62
- // Iterate over all nav links, setting the "selected" class as-appropriate.
63
- $ ( ' #nav a' ) . each ( function ( ) {
64
- var that = $ ( this ) ;
65
- that [ that . attr ( ' href' ) === hash ? ' addClass' : ' removeClass' ] ( ' selected' ) ;
66
- } ) ;
67
- } )
68
- // Since the event is only triggered when the hash changes, we need to trigger
69
- // the event now, to handle the hash the page may have loaded with.
70
- $ ( window ) . hashchange ( ) ;
63
+ // Iterate over all nav links, setting the "selected" class as-appropriate.
64
+ $ ( " #nav a" ) . each ( function ( ) {
65
+ var that = $ ( this ) ;
66
+ that [ that . attr ( " href" ) === hash ? " addClass" : " removeClass" ] ( " selected" ) ;
67
+ } ) ;
68
+ } )
69
+ // Since the event is only triggered when the hash changes, we need to trigger
70
+ // the event now, to handle the hash the page may have loaded with.
71
+ $ ( window ) . hashchange ( ) ;
71
72
72
- // To change src attribute of parent iframe element
73
- $ ( ' .hashExLink' ) . on ( ' click' , function ( ) {
74
- window . parent . document . getElementById ( "hashtagIframe" ) . src = "/resources/hashchange/example1.html" + $ ( this ) . attr ( "href" ) ;
75
- window . parent . document . getElementById ( "hashtagIframeLink" ) . innerHTML = "example1.html" + $ ( this ) . attr ( "href" ) ;
76
- } ) ;
77
- } ) ;
73
+ // To change src attribute of parent iframe element
74
+ $ ( " .hashExLink" ) . on ( " click" , function ( ) {
75
+ window . parent . document . getElementById ( "hashtagIframe" ) . src = "/resources/hashchange/example1.html" + $ ( this ) . attr ( "href" ) ;
76
+ window . parent . document . getElementById ( "hashtagIframeLink" ) . innerHTML = "example1.html" + $ ( this ) . attr ( "href" ) ;
77
+ } ) ;
78
+ } ) ;
78
79
</ script >
79
80
</ body >
80
81
</ html >
0 commit comments