jQuery Flashcards
JQuery is a _____ _____ that simplifies _____ and _______, event _______ and _______ in JavaScript mush easier.
JQuery is a JavaScript library that simplifies traversal and manipulation, event handling and animating in JavaScript mush easier.
Apart from simplifying JavaScript development, one of the main advantages of JQuery is that it works across many different ________.
Apart from simplifying JavaScript development, one of the main advantages of JQuery is that it works across many different browsers.
The jQuery library is a single JavaScript _____. It can be included within a web page by linking to a local copy, like in this example.
The jQuery library is a single JavaScript file. It can be included within a web page by linking to a local copy, like in this example.
Load the library from a CDN (Content Delivery Network). A sample CDN is used below. However, JQuery is hosted by various CDNs.
With jQuery you select (query) HTML elements and perform “actions” on them. Basic syntax is:
$(selector).action();
A ____ sign to define/access jQuery
A $ sign to define/access jQuery
A (selector) to “______” (or find) HTML elements
A (selector) to “query” (or find) HTML elements
A jQuery action() to be performed on the _________(s).
A jQuery action() to be performed on the element(s). Notice that the same action can be preformed on many elements if the query returns many items.
jQuery uses ____ _______ to select elements.
jQuery uses CSS syntax to select elements. (Complex CSS selectors can be used as the query criteria.)
Example:
//hides all paragraph elements on the page
$(“p”).hide();
//hides all elements with a class="imm" $(".imm").hide();
//hides all elements with an id="imm" $("#imm").hide();
In addition to CSS selectors, jQuery has a few more ways to target elements.
1) Existence of an attribute
2) An attribute matching a specific value (exact).
3) An attribute matching a specific value (partial)
4) Attributes containing a value at the start or end of attribute value
5) Matches the content of the element.
6) The element contains some other element
(Note:Multiple selectors can be applied by separating them by commas)
$(document).ready(function(){ // jQuery methods go here... });
Prevent any jQuery code from running before the document is finished loading (is ready).
It is good practice to wait for the document to be fully loaded and ready, before working with it. This also allows you to have your JavaScript code before the body of your document, in the head section.
Here are some examples of actions that can fail if methods are run before the document is fully loaded:
Trying to hide an element that is not created yet
Trying to get the size of an image that is not loaded yet
There are a few ways to attach events using jQuery:
1) Using the event name on a target as a function
2) Using bind() and unbind()
3) Using on and off()
4) Paired handlers like .hover()
Chaining allows us to run multiple jQuery _______, one after the other, on the _____ element(s).
Chaining allows us to run multiple jQuery commands, one after the other, on the same element(s).
Consider the following when choosing plugins:
1)
2)
3)
1) The publish date and jQuery version used
2) The author
3) Review the actual code