Appendix

Answers to Self Tests

Chapter 1: Getting Started with jQuery

1. B. C#

2. A. A Web browser

3. C. John Resig

4. A. True

5. D. MIT License

6. B. False

7. B. <script>

8. A. <head>

9. D. <script src=“jquery-1.9.1.min.js” type=“text/javascript”></script>

10. B. The file is loaded from the server that is closest to the user, improving the speed of the file download.

11. C. $()

12. A. True

13. C. anonymous function

14. A. addClass

15. C. reusable

Chapter 2: Selecting Elements in the Document

1. The $() function returns a jQuery object, which points to all of the selected elements.

2. B. Curly braces {}

3. A. It selects elements by id.

4. C. all

5. A. True

6. C. $(“.more”).addClass(“even-more”);

7. B. False

8. A. $(“div p”)

9. B. >

10. D. $(“p:not(.about-me)”)

11. B. $(“img[alt]”)

12. A. attribute equals

13. B. False

14. A. True

15. B. element at index

Chapter 3: Event Handling

1. The ready() method allows you to begin running your script as soon as all of the elements have been loaded, but it does not wait for images or other media to finish loading.

2. C. load

3. B. noConflict()

4. D. click()

5. B. False

6. A. $(“#my-element”).click(function(event) {

7. A. True

8. B. keypress

9. D. mouseenter, mouseleave

10. A. bind()

11. D. on()

12. C. off()

13. B. False

14. A. True

15. A. trigger()

Chapter 4: Working with Styles

1. When working with CSS code, you define the selector and then define a rule within a set of curly brackets ({}).

2. B. css()

3. D. var eColor = $(“#code”).css(“color”);

4. D. shorthand

5. B. False

6. A. $(“#text-box”).css(“background-color”, “#FFFFFF”);

7. A. True

8. C. +=, –=

9. D. function

10. A. removeClass()

11. C. chaining

12. B. toggleClass()

13. A. True

14. B. offset()

15. D. scrollTop()

Chapter 5: JavaScript and the Document Object Model

1. A single-line comment begins with two forward slashes (//) and ends at the end of the line.

2. C. /*, */

3. A. keywords, reserved words

4. D. null

5. A. True

6. C. backslashes ()

7. B. False

8. A. equal, data type

9. B. else

10. C. declaration

11. B. length

12. A. nodes

13. B. False

14. C. before(), insertBefore()

15. B. detach()

Chapter 6: Animations and Effects

1. The show() method displays an element by increasing its width, height, and opacity.

2. C. toggle()

3. D. slideUp()

4. A. opacity

5. A. True

6. C. fast

7. B. False (uses milliseconds)

8. A. eq()

9. B. function

10. B. indexOf()

11. D. callback function

12. A. animate()

13. A. True

14. B. False

15. A. stop()

Chapter 7: The Event Object

1. The Event object contains properties and methods that are helpful when certain events are triggered.

2. B. type

3. C. milliseconds

4. D. Math.random()

5. A. True

6. A. which

7. B. False

8. C. key

9. C. the preventDefault() method has been called

10. B. isPropagationStopped()

11. A. stopPropagation()

12. C. preventDefault()

13. B. False

14. A. True

15. D. cancelable

Chapter 8: The DOM and Forms

1. The val() method allows you to get or set values for matched elements.

2. B. $(“#yourname”).val();

3. D. $(“input[type=text]”).val(“Enter Value”);

4. A. blur

5. B. False

6. C. focus()

7. A. True

8. D. select

9. B. “cool”

10. A. test()

11. C. i

12. B. before

13. A. True

14. B. False

15. C. required

Chapter 9: Working with AJAX

1. C. Asynchronous JavaScript and XML

2. A. server

3. A. XMLHttpRequest

4. B. load()

5. A. True

6. D. asynchronously

7. A. True

8. C. find()

9. B. JavaScript Object Notation

10. A. $.getJSON()

11. C. $.get(), $.post()

12. B. callback

13. B. False

14. A. True

15. D. serialize()

Chapter 10: Using Plugins

1. B. plugins

2. A. JavaScript

3. A. a callback function

4. D. first

5. A. True

6. B. names, values

7. B. False

8. C. $(“#my-element”).start({ time: 1000, repeat: “none” });

9. A. desktop

10. B. jquery-ui.min.css, jquery-ui.min.js

11. C. animate

12. B. widgets

13. A. True

14. A. True

15. D. jCanvas

Chapter 11: Creating Plugins

1. C. $

2. B. conflicts

3. D. Math.random()

4. B. A random number from 0 to 4

5. A. True

6. A. A random number from 2 to 6

7. B. False

8. C. $.fn

9. B. this

10. A. implicit iteration

11. D. jQuery

12. A. $.extend()

13. A. True

14. B. False

15. A. callback function

Chapter 12: Advanced Techniques and Further Resources

1. B. alert()

2. A. type

3. C. “700100”

4. D. developer tools

5. A. True

6. A. issues (bugs)

7. B. False

8. C. console

9. B. console.log()

10. C. interrupt

11. A. DOM

12. C. lint

13. A. True

14. B. False

15. Any answer is correct!

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.227.52