Online - jQuery Flashcards
What is jQuery?
A public domain JavaScript library that is extremely popular and designed to make it much easier to program web apps.
What does jQuery provide?
jQuery provides a powerful set of methods for DOM manipulation and event handling that solve many of the cross-browser compatibility issues that arise when using plain JavaScript.
How does jQuery enhance the manipulation of CSS selectors and effects?
In JavaScript, if you wanted to do make same changes to a diverse collection of elements, you would need to write one expression or a set of expressions to get the collection of elements, and then you would need to write a loop to apply the changes to the collection.
But now you can use jQuery selectors to do it all in one line, like this:
$(“p,#myDiv,span.movie”).dosomething();
How would you load the jQuery library into your index.html file?
stick this in the header
What are the two ways to write the jQuery function?
jQuery( selector )
or
$( selector )
what are the two ways you can treat the object returned from a function like an array?
$(“#checkerboard”)[0].style[“borderStyle”] = “dashed”;
AND
var squares=$("td.even"); for (var i=0; i
How do you change the inner HTML using jQuery?
$(“#instructions”).html(“No more instructions!”);
How do you change the css background color using jQuery?
$(“td.odd”).css(“backgroundColor”,”blue”);
How do you change an attribute to an html element in jQuery?
$(“a”).attr(“href”, “http://www.facebook.com”);
How do you change the value of input text using jQuery?
$(“input:text”).val(“A new value”);
input:text selects all input elements of type text. There are also selectors for :button, :checkbox and so on.
How do you return values using jQuery?
You can also use each of these methods with one less parameter, and they will return the innerHTML, style property, or attribute of the first element in the matching set. Try the following:
$(“#instructions”).html();
$(“td.odd”).css(“backgroundColor”);
$(“a”).attr(“href”);
$(“input:text”).val();
How would you chain multiple methods together in jQuery?
$(“#instructions”).css(“backgroundColor”,”red”).css(“color”,”rgba(255,255,255,0.5)”).html(“Hello, World!”);
How do you change the class(es) an element belongs to in jQuery?
.important { font-weight: bold; font-size: xx-large; } .blue { color: blue; }
$(“button”).click(function(){
$(“h1, h2, p”).addClass(“blue”);
$(“div”).addClass(“important”);
});
What are some common effects and animations used in jQuery?
$(“#instructions”).fadeOut()
.fadeIn()
.animate({left:”200px”, width:”100px”})
these can be chained as well.