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 8263501
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T04:07:36+00:00 2026-06-08T04:07:36+00:00

im using a little jquery code i found on a website some time ago

  • 0

im using a little jquery code i found on a website some time ago to toggle content.
by default the content is closed and when a special link is clicked the content opens up in a smooth slide animation.
so far so good.
the problem is, that the content which is supposed to be hidden by default is visible until the page is loaded, then closes as soon as the jquery is loaded.
i have placed the jquery at the end of the page to reduce loading time for the website content.
i know this behaviour is natural but i have seen other toggle scripts before where the content that can be opened was closed even before the jquery bit loads.
the problem is that people with slow internet connections see the “hidden” part for quite some time until the page has finished loading. then the part closes because its supposed to be closed by default.

i have tried css to keep the part closed even before the jquery is loaded but the problem is that i can not open it anymore by clicking on the “show more” link because the css still forces it to stay closed..
shiatsu!!

heres the code i use:

<div class="morepara"> content that should be hidden by default can be opened by clicken on the image link below</div>

<p class="togglebutn">
<a>
<img src="/images/read-more.png" class="img-swap" aid="myImage"/>
</a>
</p>

<script type="text/javascript">
var $s = jQuery.noConflict();
$s('document').ready(function() {
    $s('.morepara div').hide();
    $s('.togglebutn a').click( function() {
        var parentpara = $s(this).parent().prev().children();
        parentpara.toggle('normal');
    });
});
$s(function() {
    $s(".img-swap").live('click', function() {
        if ($s(this).attr("class") == "img-swap") {
            this.src = this.src.replace("-more", "-less");
        } else {
            this.src = this.src.replace("-less", "-more");
        }
        $s(this).toggleClass("on");
    });
});
</script>

oh and the image-swap script works great, no problems with that part 🙂

thanks in advance! 🙂

  • 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-08T04:07:39+00:00Added an answer on June 8, 2026 at 4:07 am

    By giving your <div class="morepara"> a display:none; with CSS the div will never show up when opening the site, not even for people with a slow internet connection.

    <div class="morepara" style="display:none;">
    

    It is actually the same as: $s('.morepara').hide(); Only that one will be executed when the page is fully loaded.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a little code using jquery and I want to wait like, 300ms
I'm using jquery to send the code in some <pre> tags of my blog
I have a page which contains a jQuery-UI horizontal slider, created using a little
I recently started using JQuery and created a little slider to display logos of
I have a little problem about using jQuery (I really do not know jQuery
I'm writing myself a little game in JavaScript, using jQuery. The game has a
I have created a dynamic dependent menu using a jquery script i found on
I'm trying to put some simple jQuery code into the Wordpress header (usually just
I have a simple piece of jquery i am using to toggle the visibility
I am using the following JQuery\JavaScript code to communicate with a WCF 4 REST

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.