Solved

Javascript to fade a div

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Today I would like to talk about localizing (Internationalization) JavaScript applications. Introduction When creating an application that is going to be used by many people around the globe, it is important to remember that not everyone speak…
In my daily work (mainly using ASP.net), I need to write a lot of JavaScript code. One of the most repetitive tasks I do are the jQuery Ajax calls. You know: (CODE) I don't know if for you it's the same, but for me is soooo tedious to write the …
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…

746 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now