forked from js-workshops/intro
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path008.4-jquery.html
78 lines (74 loc) · 3.77 KB
/
008.4-jquery.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>jQuery hover()</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- add Bootstrap CSS -->
<link rel="stylesheet" href="css/bootstrap.min.css">
<link rel="stylesheet" href="css/global.css">
<!-- Place favicon.ico and apple-touch-icon.png in the root directory -->
</head>
<body>
<!--[if lt IE 7]>
<p class="browsehappy">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> to improve your experience.</p>
<![endif]-->
<!-- Page Content -->
<div class="container">
<div class="row">
<div class="col-lg-12 text-center">
<h1>jQuery hover()</h1>
<p class="lead">Let's invoke a function on the jQuery hover() event!<br />We're completing these tasks in Submlime and the console.</p>
</div>
<div class="col-lg-12">
<a class="btn btn-default" id="button" href="#" role="button">Button</a>
<br />
<br />
</div>
<div class="col-lg-12">
<p>This is an example of a hover function:</p>
<pre>
$("mySelector").hover(function() {
// hover in statement
}, function() {
// hover out statement
});
</pre>
<p>The button abovce has an ID of <code>button</code>.</p>
<ol>
<li>Open the <kbd>js/008.4-jquery.js</kbd> file in Sublime Text. It should have a <code>ready()</code> function.</li>
<li>Inside the <code>ready()</code> function, add the function above using the selector <code>#button</code>.</li>
<li>Add the code <code>console.log("hovering button");</code> inside the hover in handler of the hover function.
<ul>
<li>Hint: Add your code after the <code>// hover in statement</code></li>
</ul>
</li>
<li>Add the code <code>console.log("not hovering button");</code> inside the hover out handler of the hover function.
<ul>
<li>Hint: Add your code after the <code>// hover out statement</code></li>
</ul>
</li>
<li>Save the <kbd>js/008.4-jquery.js</kbd> file and refresh this page in your browser.</li>
<li>Hover in and out of the button above. In the console, you should see <code>hovering button</code> and <code>not hovering button</code> when those events occur.</li>
</ol>
<br />
<a href="http://api.jquery.com/hover/" target="_blank">jQuery Docs hover()</a>
</div>
<div class="col-lg-12 text-center footer">
<ul class="list-unstyled">
<li><a href="008.3-jquery.html"><< Prev</a> | <a href="008.5-jquery.html">Next >></a></li>
<li>Intro to JavaScript & jQuery - <a href="https://twitter.com/ev_blurbs">Evan Johnson</a></li>
</ul>
</div>
</div>
<!-- /.row -->
</div>
<!-- /.container -->
<!-- ADD JQUERY CDN HERE -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<!-- ADD EXTERNAL JS HERE -->
<script src="js/jq-hover.js"></script>
</body>
</html>