Reputation: 600
I am trying to make an image hidden hidden using jQuery. I am using .hide()
function. I am applying it to div containing the image which has to be hidden.
Its not working for some reason. I have created a fiddle.
Is it possible to use animate
so that the image becomes visible from right to left in say 1 sec. In other words, animate the width from 0 to maximum value but the image should become visible from left to right.
Upvotes: 3
Views: 4357
Reputation: 30676
I don't think you should animate the width because the image will look weird when resized.
You can achieve what you want like this:
overflow: hidden
and position: relative
: hiding the overflow will allow to move the image to the left out of the containerposition: absolute
and move the image to the left to hide itleft
property back to zeroUpvotes: 1
Reputation: 2471
You were not using the correct syntax.missing ); at the end of each function
$(document).ready(function() {
$('#animate').click(function() {
$('#myimage').animate({width: 'hide'},1000);
});
});
Upvotes: 2
Reputation: 2750
Here is what you want :
Please change the animations as you need.
~K
Upvotes: 1
Reputation: 7088
You can find the working jsFiddle here.
Couple of points:
)
- that's why the hiding did not work.Just for the record, I am also posting the code from the fiddle:
$(document).ready(function() {
$('#animate').click(function() {
$('#myimage').toggle('blind', { direction: 'horizontal' }, 1000);
});
});
Upvotes: 1