You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: html/lesson1/tutorial.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -306,7 +306,7 @@ Add this underneath the ordered list about why we like owls.
306
306
307
307
Some characters have special meaning in HTML. For instance, we use < and > to make HTML tags, and we use " to wrap our attributes. But what if we wanted to use those characters in our page?
308
308
309
-
One way is to use **HTML entities**. These have an ampersand, a name, then a semicolon. Here's the HTML entity for a quote character: `"`.
309
+
One way is to use **HTML entities**. These have an ampersand, a name, then a semicolon. Here's the HTML entity for a quote character: `"`.
310
310
311
311
You can also use a numerical format to produce special characters. [Here's a list](http://htmlandcssbook.com/extras/html-escape-codes/) of some common entities.
Copy file name to clipboardExpand all lines: js/lesson3/tutorial.md
+15-9Lines changed: 15 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -82,15 +82,15 @@ $('input').val("");
82
82
83
83
##Adding content
84
84
85
-
There are many different ways you can add content. You can use **append** to add something to the end to an element, or **prepend** to add to the beginning to an element.
85
+
There are many different ways you can add content. You can use **append** to add something to the end of an element, or **prepend** to add to the beginning of an element.
86
86
87
87
```js
88
88
$('#container').append("<div>I love jQuery!</div>")
89
89
```
90
90
91
91
You can also use `replaceWith()` to substitute an element entirely with some new content.
92
92
93
-
Try this out in your browser.
93
+
Open the index.html of the files provided in your browser and try this out in the JavaScript console:
94
94
95
95
```js
96
96
$('#container').replaceWith("<div>I love jQuery!</div>")
Make a note of this. Wrapping your event listeners and other code within this make's sure they are executed only after all the DOM elements are loaded and ready. You should **always** use it or else your bindings won't work and the functions will run when you are loading the page.
152
+
Make a note of this. Wrapping your event listeners and other code within this makes sure they are executed only after all the DOM elements are loaded and ready. You should **always** use it or else your bindings won't work and the functions will run before all elements on the page have loaded. So it might try to listen for events on elements that don't even exist yet and then you'll get lots of errors.
152
153
153
154
#Exercise 1: Build a wish list
154
155
155
156
Using jQuery and JavaScript functions, we will build a small todo list.
156
157
157
-
Download the files required to begin working through the example [here](https://gist.github.com/despo/309f684b7a6e002aaf1f) or alternatively checkout with git.
158
+
If you haven't yet, download the files required to begin working through the example [here](https://gist.github.com/despo/309f684b7a6e002aaf1f) or alternatively checkout with git.
@@ -165,7 +166,7 @@ Move the files under your Github page folder, in a new directory `wishlist`. Als
165
166
```bash
166
167
git commit -m "message"
167
168
```
168
-
169
+
If you don't know how to use git yet, just ignore the above for now or [look at our git tutorial](http://tutorials.codebar.io/version-control/introduction/tutorial.html).
169
170
170
171
##Functionality
171
172
- add wishes to the list by clicking the Add button
@@ -205,9 +206,11 @@ After adding the item to the list:
205
206
1. Empty the text field after adding the item to the list.
206
207
2. Use jQuery's `focus()` method to place the cursor back in the text field after clicking the button.
207
208
209
+
If you don't know how to use the focus() method, try searching for it in the [jQuery documentation](http://api.jquery.com/). There are some code examples illustrating how to use it.
210
+
208
211
###Label items
209
212
210
-
To label items, update the html of the list item being added to the list, so it includes a label.
213
+
To label items as "pending" or "done", add the below html code to the html for the new list item that you wrote at the beginning of the tutorial.
211
214
212
215
`<span class='label pending'>Pending</span>`
213
216
@@ -221,6 +224,8 @@ When we click on the Pending label, we want to set items to complete. We will do
221
224
222
225
> Use `$(this)` to access the element that the event was triggered from.
223
226
227
+
Let's go through this step by step.
228
+
224
229
Try this in the console:
225
230
226
231
First of all, bind a **click** event to the span we've added using its class with the `on()` function. As `<li>` is the parent node of the <span> element, we can access it using `parent()` (which is equivalent to `parentNode`
@@ -230,10 +235,11 @@ that we've used in the previous lesson).
230
235
var parent_node =$(this).parent();
231
236
```
232
237
233
-
> Use `attr()` to set the class attribute to `completed`or alternatively `addClass()`
238
+
> Use `attr()`or `addClass()`to set the class attribute to `completed`
234
239
235
240
> Use `remove()` to remove an element from the DOM
236
241
242
+
When you now click on the red label "pending", it should change to the green label "completed".
237
243
238
244
###Show the total task count
239
245
@@ -274,7 +280,7 @@ Have a look at our [**Wish List**](../../examples/wishlist/index.html).
274
280
https://gist.github.com/ab21d29aa1ea8fbbbb0e.git
275
281
```
276
282
277
-
Move the files under your Github page folder, in a directory colorpicker.
283
+
if you're using git, move the files under your Github page folder, in a directory colorpicker.
278
284
Don't forget to commit each task you complete! That way it will be easier to retrace your steps if something goes wrong!
0 commit comments