162 chapters 6 and 7 Flashcards
When you move your mouse over an image, it changes to another image
image rollover
To swap in another image file, you just use the ______ function to set the tag’s _____ property to a new file
attr(), src
What is the problem with swapping in a new image by changing the src and how can this problem be fixed?
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.
What does preloading an image mean?
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
What is the best way to preload a bunch of images on the same page?
by using a for loop to place each image in an array
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();
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>
What two events are required for a rollover image effect?
Mouseover and Mouseout
How many arguments does the hover() function take and what are they?
- Anonymous function telling the browser what to do when the mouse over the image
- a function telling the browser what to do when the mouse moves off the image
What does $(this) refer to?
a particular instance of an element. ie: a specific img element in a group of img elements
How can you specify the new image in the rollover loop easily and generically?
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
What method is used to change the matched text with something else in the process of creating a roll over?
replaice(‘replacementStringHere’)
In a photo gallery, ________ JavaScript means users who have JavaScript turned off will still be able to access larger versions of the photo
unobtrusive
What event is used for viewing a larger image from a thumbnail in a photo gallery?
the click event
functions that are executed in response
to an event automatically have the _____ _______ passed to them
event object
To prevent the web browser from
following the link for those who have JavaScript enabled, you run the event
object’s _______ function
preventDefault()