Solved

Javascript to fade a div

Posted on 2011-09-23
2
240 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
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…

785 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