Skip to content

Commit 365b1e4

Browse files
Add code for section 7.
1 parent d9b26b3 commit 365b1e4

File tree

15 files changed

+1229
-0
lines changed

15 files changed

+1229
-0
lines changed

07.01.focus-blur/css/style.css

Lines changed: 152 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

07.01.focus-blur/index.html

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<script src="https://code.jquery.com/jquery-1.12.3.min.js" integrity="sha256-aaODHAgvwQW1bFOGXMeX+pC4PZIPsvn2h1sArYOhgXQ=" crossorigin="anonymous"></script>
6+
<script src="js/script.js"></script>
7+
<link rel="stylesheet" href="css/style.css">
8+
<title>The Complete jQuery Course - Course Code</title>
9+
</head>
10+
<body>
11+
<div id="content">
12+
<h1>The Complete jQuery Course - Project Structure</h1>
13+
14+
<div class="red-box">Red</div>
15+
<div class="green-box">Green</div>
16+
<div class="blue-box">Blue</div>
17+
<div class="clear"></div>
18+
19+
<h2>I'm a Headline 2</h2>
20+
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Harum magnam, provident soluta beatae dolore quis, omnis cumque alias maiores itaque ea neque sapiente quaerat accusamus et illum pariatur consequuntur cum!</p>
21+
<p>Lorem ipsum <a id="link" title="An amazing link" href="/url">dolor sit amet</a>, consectetur adipisicing elit. Ut quibusdam ducimus a dolore atque maiores tempore minus pariatur, obcaecati fugit?</p>
22+
23+
<!-- A form element without class or ID -->
24+
<form action="">
25+
<input type="text" id="name" value=""><br>
26+
<input type="password" value=""><br>
27+
<textarea name="message" id="message" cols="30" rows="10"></textarea><br>
28+
<input type="submit" value="Submit">
29+
</form>
30+
31+
</body>
32+
</html>

07.01.focus-blur/js/script.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
$(function () {
2+
3+
// Select inputs
4+
var inputFields = $("input:text, input:password, textarea");
5+
6+
// Add grey box shadow when focusing any input using focus().
7+
inputFields.focus(function() {
8+
$(this).css("box-shadow", "0 0 4px #666");
9+
});
10+
11+
// Conversely, remove box shadow from other inputs when unfocusing them
12+
// using blur().
13+
inputFields.blur(function() {
14+
$(this).css("box-shadow", "none");
15+
});
16+
17+
// Add green or red background to name field, depending on whether the input
18+
// fulfills the validation criteria (here simply at least 3 characters)
19+
$("#name").blur(function() {
20+
var text = $(this).val();
21+
if (text.trim().length < 3) {
22+
$(this).css("box-shadow", "0 0 4px #811");
23+
} else {
24+
$(this).css("box-shadow", "0 0 4px #181");
25+
}
26+
});
27+
28+
});

07.02.change-event/css/style.css

Lines changed: 152 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)