jQuery Basics Flashcards

1
Q

What are the Four P’s of problem solving

A

P preparation
P planning
P Perform
P Perfect

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

What is preparation in the four P’s of problem solving?

A

The first P is preparation, where we try to understand the problem and think of a solution.

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

What is planning in the four P’s of problem solving?

A

The second P is planning, where we plan out the solution.

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

What is Perform in the four P’s of problem solving?

A

The third P is perform, where we perform what’s required for our proposed solution.

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

What is Perfect in the four P’s of problem solving?

A

Fourth is we’ll perfect our solution if there’s any mistakes or things that we haven’t considered yet.

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

.hide()

A

Hide the matched elements.

.hide()

With no parameters, the .hide() method is the simplest way to hide an element:

$( “.target” ).hide();

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

.show()

A

Display the matched elements.

.show()


With no parameters, the .show() method is the simplest way to display an element:

$( “.target” ).show();

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

How to show an element slowly.

A

$( “button” ).click(function() {
$( “p” ).show( “slow” );
});

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

.ready( handler )

A

Specify a function to execute when the DOM is fully loaded.

.ready( handler )

handler
Type: Function()
A function to execute after the DOM is ready.

* $( document ).ready( handler )
* $( handler )
$( document ).ready(function() {
  // Handler for .ready() called.
});
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

.append()

A

.append()

Insert content, specified by the parameter, to the end of each element in the set of matched elements.

.append( content [, content ] )

$( “.inner” ).append( “<p>Test</p>” );

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

.click()

A

Bind an event handler to the “click” JavaScript event, or trigger that event on an element.

.click( handler )
◦ handler
Type: Function( Event eventObject )
A function to execute each time the event is triggered.

$("button").click(function(){
    //3.1 We want to show the spoiler next to the button clicked.
  $(this).prev().show();
    //3.2 Get rid of the button
  $(this).remove();
});
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

.remove()

A

Remove the set of matched elements from the DOM.

<div class="container">
  <div class="hello">Hello</div>
  <div class="goodbye">Goodbye</div>
</div>
We can target any element for removal:

$( “.hello” ).remove();
This will result in a DOM structure with the <div> element deleted:

<div>
<div>Goodbye</div>
</div>

</div>

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

.prev()

A

Get the immediately preceding sibling of each element in the set of matched elements. If a selector is provided, it retrieves the previous sibling only if it matches that selector.

<ul>
  <li>list item 1</li>
  <li>list item 2</li>
  <li class="third-item">list item 3</li>
  <li>list item 4</li>
  <li>list item 5</li>
</ul>
To select the element that comes immediately before item three:

$( “li.third-item” ).prev().css( “background-color”, “red” );

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

.attr()

A

Get the value of an attribute for the first element in the set of matched elements.


.attr( attributeName )

$(“#imageGallery a”).click(function(event){
$(this).attr(“href”);
console.log();
});

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

event.preventDefault()

A

If this method is called, the default action of the event will not be triggered.

$( "a" ).click(function( event ) {
  event.preventDefault();
  $( "<div>" )
    .append( "default " + event.type + " prevented" )
    .appendTo( "#log" );
});</div>
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

.children()

A

Get the children of each element in the set of matched elements, optionally filtered by a selector.

.children( [selector ] )
◦ selector
Type: Selector
A string containing a selector expression to match elements against.

$( “ul.level-2” ).children().css( “background-color”, “red” );