jQuery Basics Flashcards

1
Q

shorthand for jQuery

A

$

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

select the element with the CSS class of warning

A

$(“.warning”)

Remember that CSS classes start with a period

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

hide warning when the page loads and then show it slowly

A

$(“.warning).hide().show(“slow”)

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

open Chrome Developer Tools

A

Command + Option (Alt) + J

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

go over to previous line of code

A

the up key

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

display the function myCode after the DOM has loaded

A

$(document).ready(myCode)

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

add a button to the spoiler class

A

$(“.spoiler).append(“Reveal Spoiler “);

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

add a click handler to the button, show the spoiler and remove the button

A

$(“button”).click(function(){
$(“.spoiler.span”).show();
$(this).remove();
});

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

show the spoiler next to the button clicked

A

$(this).prev().show();

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

Capture the click event on a link to an image (with the ul id=”imageGallery”)

A

$(“#imageGallery a”).click();

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

prevent browser default behavior

A

$(“#imageGallery a”).click(function(event){

event.preventDefault();

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

Using jQuery only, add to all links with the class “external”, the target attribute with the value of “_blank”.

A

$(“a.external”).attr(“target”,”_blank”);

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

create a detached select object of the DOM

A

$select = $(“”);

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

A prompt dialog will open prompting for someone’s full name. Use jQuery to follow the comments in code. First, select the correct input, and then set its value to the fullName.

//Show Prompt Window and store value
var fullName = prompt("What is your full name?");
//Select Input with the id of #fullName
//Insert value in to full name input
A
//Show Prompt Window and store value
var fullName = prompt("What is your full name?");
//Select Input with the id of #fullName
//Insert value in to full name input
$('#fullName').val(fullName);
/* $('#fullName') -> selects the input with this id.
   .val() -> JQuery method to get a value from an element or set the value if a value is passed.
   In this case, we set the value of the input to the value we get from the prompt.
*/
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

use a single jQuery method to either show or hide the $(“#colorSelect”)

A

$(“#colorSelect”).toggle();

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