jQuery Fundamentals

JQuery fundamentals vi. Create a portlet module … Custom events…Manipulating Elements … Getting and Setting Information about Elements … Moving, Copying, and Removing Elements … Creating New Elements.

More PDF Content

jQuery Fundamentals, List of Examples
1.1. An example of inline Javascript … 1
1.2. An example of including external JavaScript … 1
1.3. Example of an example … 3
2.1. A simple variable declaration … 5
2.2. Whitespace has no meaning outside of quotation marks … 5
2.3. Parentheses indicate precedence … 5
2.4. Tabs enhance readability, but have no special meaning … 5
2.5. Concatenation … 5
2.6. Multiplication and division … 6
2.7. Incrementing and decrementing … 6
2.8. Addition vs. concatenation … 6
2.9. Forcing a string to act as a number … 6
2.10. Forcing a string to act as a number (using the unary-plus operator) … 6
2.11. Logical AND and OR operators … 6
2.12. Comparison operators … 7
2.13. Flow control … 8
2.14. Values that evaluate to true … 8
2.15. Values that evaluate to false … 8
2.16. The ternary operator … 9
2.17. A switch statement … 9
2.18. Loops … 10
2.19. A typical for loop … 10
2.20. A typical while loop … 11
2.21. A while loop with a combined conditional and incrementer … 11
2.22. A do-while loop … 11
2.23. Stopping a loop … 12
2.24. Skipping to the next iteration of a loop … 12
2.25. A simple array … 14
2.26. Accessing array items by index … 14
2.27. Testing the size of an array … 14
2.28. Changing the value of an array item … 15
2.29. Adding elements to an array … 15
2.30. Working with arrays … 15
2.31. Creating an object literal … 15
2.32. Function Declaration … 16
2.33. Named Function Expression … 16
2.34. A simple function … 16
2.35. A function that returns a value … 16
2.36. A function that returns another function … 16
2.37. A self-executing anonymous function … 17
2.38. Passing an anonymous function as an argument … 17
2.39. Passing a named function as an argument … 17
2.40. Testing the type of various variables … 18
2.41. Functions have access to variables defined in the same scope … 19
2.42. Code outside the scope in which a variable was defined does not have access to the variable… 19
2.43. Variables with the same name can exist in different scopes with different values … 19
2.44. Functions can see changes in variable values after the function is defined … 19
2.45. Scope insanity … 20
2.46. How to lock in the value of i? … 20
2.47. Locking in the value of i with a closure … 20
3.1. A $(document).ready() block … 22
3.2. Shorthand for $(document).ready() … 22
3.3. Passing a named function instead of an anonymous function … 22
3.4. Selecting elements by ID … 22
3.5. Selecting elements by class name … 22
3.6. Selecting elements by attribute … 23
3.7. Selecting elements by compound CSS selector … 23
3.8. Pseudo-selectors … 23
3.9. Testing whether a selection contains elements … 24
3.10. Storing selections in a variable … 25
3.11. Refining selections … 25
3.12. Using form-related pseduo-selectors … 26
3.13. Chaining … 26
3.14. Formatting chained code … 26
3.15. Restoring your original selection using $.fn.end … 26
3.16. The $.fn.html method used as a setter … 27
3.17. The html method used as a getter … 27
3.18. Getting CSS properties … 27
3.19. Setting CSS properties … 27
3.20. Working with classes … 28
3.21. Basic dimensions methods … 28
3.22. Setting attributes … 28
3.23. Getting attributes … 29
3.24. Moving around the DOM using traversal methods … 29
3.25. Iterating over a selection … 29
3.26. Changing the HTML of an element … 30
3.27. Moving elements using different approaches … 31
3.28. Making a copy of an element … 31
3.29. Creating new elements … 32
3.30. Creating a new element with an attribute object … 32
3.31. Getting a new element on to the page … 32
3.32. Creating and adding an element to the page at the same time … 32
3.33. Manipulating a single attribute … 33
3.34. Manipulating multiple attributes … 33
3.35. Using a function to determine an attribute\’s new value … 33
4.1. Checking the type of an arbitrary value … 37
4.2. Storing and retrieving data related to an element … 37
4.3. Storing a relationship between elements using $.fn.data … 37
4.4. Putting jQuery into no-conflict mode … 38
4.5. Using the $ inside a self-executing anonymous function … 38
5.1. Event binding using a convenience method … 39
5.2. Event biding using the $.fn.bind method … 39
5.3. Event binding using the $.fn.bind method with data … 39
5.4. Switching handlers using the $.fn.one method … 40
5.5. Unbinding all click handlers on a selection … 40
5.6. Unbinding a particular click handler … 40
5.7. Namespacing events … 40
5.8. Preventing a link from being followed … 41
5.9. Triggering an event handler the right way … 41
5.10. Event delegation using $.fn.delegate … 42
5.11. Event delegation using $.fn.live … 42
5.12. Unbinding delegated events … 42
5.13. The hover helper function … 42
5.14. The toggle helper function … 43
6.1. A basic use of a built-in effect … 45
6.2. Setting the duration of an effect … 45
6.3. Augmenting jQuery.fx.speeds with custom speed definitions … 46
6.4. Running code when an animation is complete … 46
6.5. Run a callback even if there were no elements to animate … 46
6.6. Custom effects with $.fn.animate … 46
6.7. Per-property easing … 47
7.1. Using the core $.ajax method … 51
7.2. Using jQuery\’s Ajax convenience methods … 53
7.3. Using $.fn.load to populate an element … 54
7.4. Using $.fn.load to populate an element based on a selector … 54
7.5. Turning form data into a query string … 54
7.6. Creating an array of objects containing form data … 54
7.7. Using YQL and JSONP … 55
7.8. Setting up a loading indicator using Ajax Events … 55
8.1. Creating a plugin to add and remove a class on hover … 60
8.2. The Mike Alsup jQuery Plugin Development Pattern … 61
8.3. A simple, stateful plugin using the jQuery UI widget factory … 62
8.4. Passing options to a widget … 63
8.5. Setting default options for a widget … 63
8.6. Creating widget methods … 64
8.7. Calling methods on a plugin instance … 65
8.8. Responding when an option is set … 65
8.9. Providing callbacks for user extension … 66
8.10. Binding to widget events … 67
8.11. Adding a destroy method to a widget … 68
10.1. An object literal … 79
10.2. Using an object literal for a jQuery feature … 80
10.3. The module pattern … 81
10.4. Using the module pattern for a jQuery feature … 83
10.5. Using RequireJS: A simple example … 84
10.6. A simple JavaScript file with dependencies … 85
10.7. Defining a RequireJS module that has no dependencies … 86
10.8. Defining a RequireJS module with dependencies … 86
10.9. Defining a RequireJS module that returns a function … 86
10.10. A RequireJS build configuration file … 87

Download jQuery Fundamentals pdf from jqfundamentals.com, 106 pages, 499.64KB.
Related Books

Leave a Reply