Online - jQuery Flashcards

1
Q

What is jQuery?

A

A public domain JavaScript library that is extremely popular and designed to make it much easier to program web apps.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What does jQuery provide?

A

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 well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How does jQuery enhance the manipulation of CSS selectors and effects?

A

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 well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How would you load the jQuery library into your index.html file?

A

stick this in the header

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What are the two ways to write the jQuery function?

A

jQuery( selector )
or
$( selector )

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

what are the two ways you can treat the object returned from a function like an array?

A

$(“#checkerboard”)[0].style[“borderStyle”] = “dashed”;

AND

var squares=$("td.even"); 
for (var i=0; i
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How do you change the inner HTML using jQuery?

A

$(“#instructions”).html(“No more instructions!”);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How do you change the css background color using jQuery?

A

$(“td.odd”).css(“backgroundColor”,”blue”);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

How do you change an attribute to an html element in jQuery?

A

$(“a”).attr(“href”, “http://www.facebook.com”);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How do you change the value of input text using jQuery?

A

$(“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 well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

How do you return values using jQuery?

A

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 well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

How would you chain multiple methods together in jQuery?

A

$(“#instructions”).css(“backgroundColor”,”red”).css(“color”,”rgba(255,255,255,0.5)”).html(“Hello, World!”);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

How do you change the class(es) an element belongs to in jQuery?

A
.important {
    font-weight: bold;
    font-size: xx-large;
}
.blue {
    color: blue;
}

$(“button”).click(function(){
$(“h1, h2, p”).addClass(“blue”);
$(“div”).addClass(“important”);
});

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What are some common effects and animations used in jQuery?

A

$(“#instructions”).fadeOut()
.fadeIn()
.animate({left:”200px”, width:”100px”})

these can be chained as well.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly