162 chapters 6 and 7 Flashcards

1
Q

When you move your mouse over an image, it changes to another image

A

image rollover

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

To swap in another image file, you just use the ______ function to set the tag’s _____ property to a new file

A

attr(), src

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

What is the problem with swapping in a new image by changing the src and how can this problem be fixed?

A

If you wait till someone mouses over an image before downloading the new graphic there will be a delay. You can preload the new image.

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

What does preloading an image mean?

A

forcing the browser to download the image before you plan on displaying it by storing it in the web browser’s cache so that any requests for that file are served from the user’s hard drive instead of from the web server

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

What is the best way to preload a bunch of images on the same page?

A

by using a for loop to place each image in an array

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q
In the following code, what is happening in line 7?
1 $('#gallery a').click(function(evt) {
2        evt.preventDefault();
3        var imgPath = $(this).attr('href');
4        var oldImage = $('#photo img');
5        var newImage = $('<img>');
6       newImage.hide();
7       $('#photo').prepend(newImage);
8       newImage.fadeIn(1000);
9       oldImage.fadeOut(1000,function(){
10            $(this).remove();
11      }); // end fadeout
12 }); // end click
13 $('#gallery a:first').click();
A

The prepend() function is used to add the HTML inside (at the very beginning) of the tag causing the photo <div> to have two images on top of each other with the top image being invisible.</div>

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

What two events are required for a rollover image effect?

A

Mouseover and Mouseout

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

How many arguments does the hover() function take and what are they?

A
  1. Anonymous function telling the browser what to do when the mouse over the image
  2. a function telling the browser what to do when the mouse moves off the image
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What does $(this) refer to?

A

a particular instance of an element. ie: a specific img element in a group of img elements

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

How can you specify the new image in the rollover loop easily and generically?

A

Store the original and new images in the same folder and name them similarly. The path to the original and new image remains the same.
example: add _hover to the end of all new images in the folder dog<– new image

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

What method is used to change the matched text with something else in the process of creating a roll over?

A

replaice(‘replacementStringHere’)

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

In a photo gallery, ________ JavaScript means users who have JavaScript turned off will still be able to access larger versions of the photo

A

unobtrusive

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

What event is used for viewing a larger image from a thumbnail in a photo gallery?

A

the click event

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

functions that are executed in response

to an event automatically have the _____ _______ passed to them

A

event object

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

To prevent the web browser from
following the link for those who have JavaScript enabled, you run the event
object’s _______ function

A

preventDefault()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q
What does $(this) refer to in the following code:
$('#gallery a').click(function(evt) {
      evt.preventDefault();
      var imgPath = $(this).attr(‘href’);
}); // end click
A

The element that is clicked

17
Q

A link’s ______ attribute points to the page or resource the link goes to

A

href

18
Q
In the following code, \_\_\_\_\_\_\_\_ selects all images on the page:
1 $('#gallery a').click(function(evt) {
2        evt.preventDefault();
3        var imgPath = $(this).attr('href');
4        var oldImage = $('#photo img');
5        var newImage = $('<img>');
6       newImage.hide();
7       $('#photo').prepend(newImage);
8       newImage.fadeIn(1000);
9       oldImage.fadeOut(1000,function(){
10            $(this).remove();
11      }); // end fadeout
12 }); // end click
13 $('#gallery a:first').click();
A

$(‘img’)

19
Q
In the following code, what is happening in line 5?
1 $('#gallery a').click(function(evt) {
2        evt.preventDefault();
3        var imgPath = $(this).attr('href');
4        var oldImage = $('#photo img');
5        var newImage = $('<img>');
6       newImage.hide();
7       $('#photo').prepend(newImage);
8       newImage.fadeIn(1000);
9       oldImage.fadeOut(1000,function(){
10            $(this).remove();
11      }); // end fadeout
12 }); // end click
13 $('#gallery a:first').click();
A

it creates a new <img></img> tag by concatinating three strings and stores it in a variable named newImage

20
Q
In the following code, \_\_\_\_\_\_\_\_ holds a jQuery selection containing the <img> tag inside
the photo <div> :
1 $('#gallery a').click(function(evt) {
2        evt.preventDefault();
3        var imgPath = $(this).attr('href');
4        var oldImage = $('#photo img');
5        var newImage = $('<img>');
6       newImage.hide();
7       $('#photo').prepend(newImage);
8       newImage.fadeIn(1000);
9       oldImage.fadeOut(1000,function(){
10            $(this).remove();
11      }); // end fadeout
12 }); // end click
13 $('#gallery a:first').click();</div>
A

oldImage

21
Q
In the following code, what is happening in line 6?
1 $('#gallery a').click(function(evt) {
2        evt.preventDefault();
3        var imgPath = $(this).attr('href');
4        var oldImage = $('#photo img');
5        var newImage = $('<img>');
6       newImage.hide();
7       $('#photo').prepend(newImage);
8       newImage.fadeIn(1000);
9       oldImage.fadeOut(1000,function(){
10            $(this).remove();
11      }); // end fadeout
12 }); // end click
13 $('#gallery a:first').click();
A

The image stored in the newImage variable is

hidden using the hide() function

22
Q

A ______ image is just an image swap

A

rollover

23
Q

when does the callback() function run?

A

after the fade out effect finishes