3 <title>Hover tests
</title>
4 <script src=
"jquery.js"></script>
6 /* Remove body dimensions so we can test enter/leave to surrounding browser chrome */
18 margin:
10px
40px
20px
0;
34 <h2>Hover (mouse{over,out,enter,leave}) Tests
</h2>
35 <p>Be sure to try moving the mouse out of the browser via the left side on each test.
</p>
38 <div id=
"hoverbox" class=
"hover-box">
39 <div class=
"hover-status">
40 <button>Activate
</button>
41 .hover() in/out:
<span class=
"ins">0</span> /
<span class=
"outs">0</span>
43 <div class=
"hover-inside">
44 Mouse over here should NOT trigger the counter.
47 <div id=
"liveenterbox" class=
"hover-box">
48 <div class=
"hover-status">
49 <button>Activate
</button>
50 Live enter/leave:
<span class=
"ins">0</span> /
<span class=
"outs">0</span>
52 <div class=
"hover-inside">
53 Mouse over here should NOT trigger the counter.
56 <div id=
"delegateenterbox" class=
"hover-box">
57 <div class=
"hover-status">
58 <button>Activate
</button>
59 Delegated enter/leave:
<span class=
"ins">0</span> /
<span class=
"outs">0</span>
61 <div class=
"hover-inside">
62 Mouse over here should NOT trigger the counter.
66 <div id=
"overbox" class=
"hover-box">
67 <div class=
"hover-status">
68 <button>Activate
</button>
69 Bind over/out:
<span class=
"ins">0</span> /
<span class=
"outs">0</span>
71 <div class=
"hover-inside">
72 Mouse over here SHOULD trigger the counter.
75 <div id=
"liveoverbox" class=
"hover-box">
76 <div class=
"hover-status">
77 <button>Activate
</button>
78 Live over/out:
<span class=
"ins">0</span> /
<span class=
"outs">0</span>
80 <div class=
"hover-inside">
81 Mouse over here SHOULD trigger the counter.
84 <div id=
"delegateoverbox" class=
"hover-box">
85 <div class=
"hover-status">
86 <button>Activate
</button>
87 Delegated over/out:
<span class=
"ins">0</span> /
<span class=
"outs">0</span>
89 <div class=
"hover-inside">
90 Mouse over here SHOULD trigger the counter.
94 </div> <!-- wrapper -->
101 countIns = function() {
102 var d
= $(this).data();
103 $("span.ins", this).text(++d
.ins
);
105 countOuts = function() {
106 var d
= $(this).data();
107 $("span.outs", this).text(++d
.outs
);
110 // Tests can be activated separately or in combination to check for interference
112 $("#hoverbox button").click(function(){
114 .data({ ins
: 0, outs
: 0 })
115 .hover( countIns
, countOuts
);
118 $("#delegateenterbox button").click(function(){
120 .find("#delegateenterbox").data({ ins
: 0, outs
: 0 }).end()
121 .delegate("#delegateenterbox", "mouseenter", countIns
)
122 .delegate("#delegateenterbox", "mouseleave", countOuts
);
125 $("#liveenterbox button").click(function(){
127 .data({ ins
: 0, outs
: 0 })
128 .live("mouseenter", countIns
)
129 .live("mouseleave", countOuts
);
133 $("#overbox button").click(function(){
135 .data({ ins
: 0, outs
: 0 })
136 .bind("mouseover", countIns
)
137 .bind("mouseout", countOuts
);
140 $("#liveoverbox button").click(function(){
142 .data({ ins
: 0, outs
: 0 })
143 .live("mouseover", countIns
)
144 .live("mouseout", countOuts
);
147 $("#delegateoverbox button").click(function(){
149 .find("#delegateoverbox").data({ ins
: 0, outs
: 0 }).end()
150 .delegate("#delegateoverbox", "mouseover", countIns
)
151 .delegate("#delegateoverbox", "mouseout", countOuts
);