I have a .hide()
function that hides divs based on checkboxes.
JS Fiddle of it working here Real site example here
I'm trying to give it animation so that the .hide()
will fade in/out rather than just disappear.
Tried utilising the jQuery Fade function but as a parameter for .hide()
but doesn't seem to work
$("div").click(function () { $(this).hide("fade", {}, 1000); });
I tried using this in my code (see JS Fiddle) as the following:
if(allSelected.length > 0){ $("div.prodGrid > div:not(" + allSelected + ")").hide("fade", {}, 1000); }
Where am I going wrong?
The jQuery fadeIn() method is used to fade in a hidden element.
jQuery Effect fadeOut() MethodThe fadeOut() method gradually changes the opacity, for selected elements, from visible to hidden (fading effect). Note: Hidden elements will not be displayed at all (no longer affects the layout of the page). Tip: This method is often used together with the fadeIn() method.
fadeOut() the place will be removed at once. . show(duration) and . hide(duration) animate the size of element (also the opacity) to 100% and 0% and the place of elements is also animated in that duration.
5) Which of the following jQuery method is used to hide the selected elements? Explanation: The jQuery hide() method is used to hide the selected elements.
$("div").click(function () { $(this).fadeOut(1000); })
There are also fadeIn
and fadeToggle
.
You might use @Arnelle's solution if you want to fadeOut or
replace $(this).hide("fade", {}, 1000);
with
$(this).hide("slow");//or $(this).hide(1000);
passing "slow" will give a nice animation before hiding your div.
Modified your fiddle with changes: http://jsfiddle.net/Z9ZVk/8/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With