?
Solved

Javascript to fade a div

Posted on 2011-09-23
2
Medium Priority
?
256 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 13

Accepted Solution

by:
ansudhindra earned 1400 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 600 total points
ID: 36588434
You are missing the `#` from your div selectors. Use
$("#secondary-cont-content") 

Open in new window

0

Featured Post

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

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

In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
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…
Suggested Courses

777 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