Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9259037
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T12:33:33+00:00 2026-06-18T12:33:33+00:00

I’m trying to load content from wordpress pages into a div on a custom

  • 0

I’m trying to load content from wordpress pages into a div on a custom template using links.

I have one div that is hidden, and should be displayed with slideDown when content is loaded into it.

I have several links to different pages that I want to be loaded into this one div by onClick, or something similar.

Example:

Lets say I have the following links:

– Link 1 (home)

– Link 2 (about)

– Link 3 (contact)

If a visitor clicks these links something like this should happen:

Click link 2 –> load into div –> div gets displayed with slideDown
or similar.

Click link 3 –> previous loaded content fades out and content of link
2 fades in

Click link 2 (again) –> similar action as by click og link 2…

Click link 1 –> clears div and hides it by slideUp or similar.

If Link 2 or 3 is active, and the user clicks the same link again –>
similar action as by click of Link 1

I have found some bits of code to help me on the way, but I’m not quite there yet.
Heres what I have so far:

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.js" type="text/javascript"></script>
<script type="text/javascript">
$(function() {
      $('#navigationMenu a').click(function() { // When a menu item is selected
            $('#maincontent').load($(this).attr('href')); // Load its linked page into the div
            return false; // And prevent it following the link
      });
});

function toggleSlider() {
    if ($("#maincontent").is(":visible")) {
        $("#sec-content").animate(
            {
                opacity: "0"
            },
            600,
            function(){
                $("#maincontent").slideUp();
            }
        );
    }
    else {
        $("#maincontent").slideDown(600, function(){
            $("#sec-content").animate(
                {
                    opacity: "1"
                },
                600
            );
        });
    }   
}

</script>

I have found this code in related posts here on SO, and this makes me load the content into the div with slideUp/slide/down functionality.
BUT it closes the div by click on link 3 (in the example), so I’ll have to click the link again to load it once more.
And the home link, Link 1, doesn’t do what I want yet.

Hope someone with a little more knowledge about this can help me out here.
Is it at all possible to do?

Thanks!

—- Edited code 02/08/13 —-

<script type="text/javascript">

$(function() {
      $('#navigationMenu a').click(function() { // When a menu item is selected
            $('#maincontent').load($(this).attr('href')); // Load its linked page into the div
            return false; // And prevent it following the link
      });
});

var lastData;
$(function () {
    $("a").click(function(event) {
        loadData($(this).attr("href"));
        event.preventDefault();
    });
});

function loadData(data) {
    if(lastData == data) {
        $("#maincontent").slideUp();
    } else {
        $("#maincontent").html(data);
        $("#maincontent").slideDown();
    }
    lastData = data;
}

</script>

The result can be seen at http://tobba.org/no

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T12:33:34+00:00Added an answer on June 18, 2026 at 12:33 pm

    You could try having a function that says: When a link is clicked, see if it was the last link clicked. If so, then slideUp(). If not, then get the data to go in there, and then once the data is available, fill the box and slideDown.

    This example might get you halfway, you’ll still need to use $.get or $.load to get the data you want. NOTE: lastData is declared outside of the scope of the function so that it doesn’t lose its value when the function ends:
    http://jsfiddle.net/turiyag/9na6K/

    function loadData(data) {
        if(lastData == data) {
            $("#dataview").slideUp();
        } else {
            $("#dataview").html(data);
            $("#dataview").slideDown();
        }
        lastData = data;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to find ID3V2 tags from MP3 file using jid3lib in Java.
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am using JSon response to parse title,date content and thumbnail images and place
this is what i have right now Drawing an RSS feed into the php,
I am using the SimpleRSS gem to parse a WordPress RSS feed. The only
I have a French site that I want to parse, but am running into
I have a text area in my form which accepts all possible characters from
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.