I'm trying to make sure that when the link is clicked, the div (with some paragraphs and text) is deleted and the other div is inserted (with some paragraphs and some text). I use jQuery to fade them out. The attenuation of the original div works when you click on the link, and then I have a switch case to determine what fades. However, fadeIn set to "slow" seems to happen immediately.
Here's the corresponding code snippet (the rest are just different cases):
$(document).ready(function() { $('.nav-link').click(function() { var linkClicked = $(this).attr("id"); $('.content').fadeOut('fast'); switch(linkClicked) { case 'home': console.log("linkClicked = "+linkClicked); $('#home-content').fadeIn('slow', function() { $(this).css("display", "inline"); $(this).css("opacity", 100); }); break;
Edit:
So, changing fadeTo to fadeOut and changing βslowβ in fadeOut to βfastβ, it worked fine and switched as I want. However, whenever I press βhomeβ, now it moves the div to the βblockβ position (he spits it out in the lower left corner) before sitting back in the right place in the center of my container. It ONLY does this when I click on a house, and none of my other sidenav links ... that all work with the same code (the house is just the first in the case of a switch). Any ideas?
source share