Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialRifqi Fahmi
23,164 Pointsimprove overlay
I want to make the image show up slow and when I close the image it also do the same. I have code
var overlay = $("<div id='overlay'></div>");
var image = $('<img>');
overlay.append(image.hide());
$('body').append(overlay);
$('#gallery a').click(function(event) {
event.preventDefault();
var imageLocation = $(this).attr('href');
image.attr('src', imageLocation)
image.css('width: 200');
overlay.show();
image.show('slow');
});
overlay.click(function() {
overlay.hide().ready(image.hide('slow'));
});
when I click the image open with slow but when I close the image, the slow effect didn't affect the image. how to fix this.
thanks :)
3 Answers
Falk Schwiefert
8,706 Pointsoverlay.click(function() {
overlay.hide('slow').ready(image.hide('slow'));
});
Falk Schwiefert
8,706 PointsYou might have to separate the image hide and overlay hid functions. However, just another JS noob here. :)
Rifqi Fahmi
23,164 Pointsbtw thanks for answering. me too here :)
Tobiasz Gala
Full Stack JavaScript Techdegree Student 23,529 Pointshide() has more parameters
overlay.click(function() {
image.hide('slow', function() {
overlay.hide();
});
Rifqi Fahmi
23,164 PointsRifqi Fahmi
23,164 Pointsnope, it will make the overlay disappear slowly. all I want are the image disappear slowly first then the overlay disappear without slow effect. hmmmmmm