1
+ <!doctype html>
2
+ < html >
3
+ < head >
4
+ < meta charset ="utf-8 " />
5
+
6
+ < title >
7
+ Keep Overflow Content Scrolling Unresponsive Until Clicked Using jQuery
8
+ </ title >
9
+
10
+ < style type ="text/css ">
11
+
12
+ div .overflowable {
13
+ border : 2px solid # FF3399 ;
14
+ height : 150px ;
15
+ overflow : auto ;
16
+ padding : 1px 16px 1px 16px ;
17
+ width : 500px ;
18
+ }
19
+
20
+ div .overflowable .unresponsive {
21
+ border-color : # CCCCCC ;
22
+ cursor : pointer ;
23
+ overflow : hidden ;
24
+ }
25
+
26
+ </ style >
27
+ </ head >
28
+ < body >
29
+
30
+ < h1 >
31
+ Keep Overflow Content Scrolling Unresponsive Until Clicked Using jQuery
32
+ </ h1 >
33
+
34
+ < p >
35
+ Here is a long page; but, on the page, we have another
36
+ area of content that can be scrolled independently using
37
+ CSS overflow.
38
+ </ p >
39
+
40
+ < p >
41
+ < strong > Content You Don't Really Care About</ strong > :
42
+ </ p >
43
+
44
+ <!-- BEGIN: Overflow Content. -->
45
+ < div class ="overflowable unresponsive ">
46
+
47
+ < p class ="repeatMe ">
48
+ This is the sub-content area - independently scrollable.
49
+ </ p >
50
+
51
+ </ div >
52
+ <!-- END: Overflow Content. -->
53
+
54
+ < p class ="repeatMe ">
55
+ This is part of the main page content.
56
+ </ p >
57
+
58
+
59
+ <!-- Load scripts. -->
60
+ < script type ="text/javascript " src ="../../vendor/jquery/jquery-2.0.3.min.js "> </ script >
61
+ < script type ="text/javascript ">
62
+
63
+ // When the content area is clicked, remove the "unresponsive"
64
+ // class. This will allow the overflow to take on the "auto"
65
+ // behavior, instead of the "hidden" behavior.
66
+ $ ( "div.overflowable" ) . click (
67
+ function ( event ) {
68
+
69
+ $ ( this ) . toggleClass ( "unresponsive" ) ;
70
+
71
+ }
72
+ ) ;
73
+
74
+ // Set up the "filler" content to make the page and the
75
+ // sub-content scroll-worthy.
76
+ $ ( "p.repeatMe" ) . each (
77
+ function ( ) {
78
+
79
+ var root = $ ( this ) ;
80
+
81
+ for ( var i = 0 ; i < 20 ; i ++ ) {
82
+
83
+ root . after ( $ . clone ( this ) ) ;
84
+
85
+ }
86
+
87
+ }
88
+ ) ;
89
+
90
+ </ script >
91
+
92
+ </ body >
93
+ </ html >
0 commit comments