JQuery Flashcards
What is a Java library?
A reusable bundle of JavaScript functionality. Its JavaScript code stored on a server. It can be accessed and reused by others.
What is a CDN?
A content delivery network is a server optimized for serving static files like JS libraries and doing it very quickly.
How does a library fit into the design of a webpage?
A webpage is made up of the user interface (HTML+CSS), interactivity (JS+DOM), and data (which we often bring in through JS). A JS library may take the place of any or all of these parts.
What is jQuery?
It is the most popular JavaScript library. It give developers lots of useful functions so they can make their webpage interactive across multiple browsers. It is an open source library with a big community of contributors.
What is the main function in jQuery?
$. $(“h1”) finds all the h1’s on a page and stores them in a collection (array).
How does JQuery change text of a tag?
$(“p”).text(“message”);
What is the syntax of selectors in the JQuery function?
$(“p”);
$(“#identifierName”);
$(“.className”);
How is jQuery used to get text from an element?
var variableName = $("#identifierName").text(); The method call with no variables passed to the method returns what is inside the tag with the identity of identifierName.
What is the general way to associate an element with a variable using jQuery?
var $variableName = $(“#identifierName”);
It is customary to use a $ to start a variable that stores jQuery object.
Then you can $variableName.text() to get text. You would also say $variableName.text($variableName.text() + “new text to append to the old stuff”);
What is the method for passing HTML rather than just text?
.html rather than .text
How is a class name added to an element?
$(“a”).addClass(“className”);
How is a CSS rule added to an element?
$(“a”).css(“color”, “green”);
How is an attribute changed or added to an element?
$(“a”).attr(“href”, “URL”);
How is an element created and added to a webpage?
var $newP=$(“<p>”);
$(“body”).append($newP);</p>
What is the difference between a DOM element and a jQuery collection?
1. The DOM node is stored using var nameEL=document.getElementById("identifierName"); The jQuery collection is stored using var $nameEL=$("#identifierName"); 2. Each item in the jQuery collection is a DOM node.
- The jQuery collection includes more methods to manipulate the data than a DOM node.