Solved

Javascript to fade a div

Posted on 2011-09-23
2
246 Views
Last Modified: 2012-06-21
How do I need to fix the following code so it will fade in and fade out a specific div ID?

The div id I want to focus on is: #secondary-cont-content

$(document).ready(function() {
    $("secondary-cont-content").css("display", "none");
 
    $("secondary-cont-content").fadeIn(1000);
 
    $("a.transition").click(function(event){
        event.preventDefault();
        linkLocation = this.href;
        $("secondary-cont-content").fadeOut(1000, redirectPage);
    });
 
    function redirectPage() {
        window.location = linkLocation;
    }
});

Open in new window

0
Comment
Question by:rgranlund
2 Comments
 
LVL 13

Accepted Solution

by:
ansudhindra earned 350 total points
ID: 36588295
try

$(document).ready(function() {
    $("#secondary-cont-content").css("display", "none");
 
    $("#secondary-cont-content").fadeIn(1000);
 
    $("a.transition").click(function(event){
        event.preventDefault();
        linkLocation = this.href;
        $("secondary-cont-content").fadeOut(1000, redirectPage);
    });
 
    function redirectPage() {
        window.location = linkLocation;
    }
});
0
 
LVL 2

Assisted Solution

by:WizardOfOgz
WizardOfOgz earned 150 total points
ID: 36588434
You are missing the `#` from your div selectors. Use
$("#secondary-cont-content") 

Open in new window

0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses how to create an extensible mechanism for linked drop downs.
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question