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

  • Home
  • SEARCH
  • 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 4012912
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T09:18:22+00:00 2026-05-20T09:18:22+00:00

I am using slideToggle to show some data in a div. Here’s my code:

  • 0

I am using slideToggle to show some data in a div. Here’s my code:

$('a.more').click(function(event){
            event.preventDefault();            
            var id = $(this).attr('cid');
            $.post('<?php echo $this->baseUrl('/teacher/class-members');?>',
            {cid: id},
            function(data) {                              
                $("div[cid='" + id + "']").slideToggle(500, function(){
                    $(this).html(data);
                });
            })
        });

The problem is that I need to click 2 times for the slide to activate and show the data. Why is this happening? It only needs to do this one time per link. So when I’m first viewing a page and I click on a link with class “more” I need to click 2 times (the $.post is executed 2 times :-/ ) for the toggle to work. After that It will work as it should, 1 click toggle down, 1 click toggle up.

  • 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-05-20T09:18:22+00:00Added an answer on May 20, 2026 at 9:18 am

    What is the initial css state of div[cid=, if it is set to display block it will hide the div and than assign the html in the callback.

    If you set the div to display:none it should work the first time however it will be jumpy as it only will set the html on the callback of slideToggle.

    If you want to slide up on each click and load the data try this out:

    $('a.more').click(function (event) {
        event.preventDefault();
        var id = $(this).attr('cid');
        var $div = $("div[cid='" + id + "']").slideUp(function(){$(this).empty();});
        $.post('<?php echo $this->baseUrl(' / teacher / class - members ');?>', {
            cid: id
        }, function (data) {
            $div.html(data).slideDown(500);
        })
    });
    

    Example on jsfiddle.

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

Sidebar

Related Questions

I'm using this jQuery to hide a DIV: $(#slider).click(function() { $(.help).slideToggle(); $(#wrapper).animate({ opacity: 1.0
Using preview 4 of ASP.NET MVC Code like: <%= Html.CheckBox( myCheckBox, Click Here, True,
I'm using a button to slideToggle the display of my disclaimer here, and for
Im using jquery 1.3.2 and this is the code: <script type=text/javascript> //<![CDATA[ jQuery(function(){ jQuery('.news_bullet
I'm trying to use jQuery's slideToggle function to show or hide a panel which
I'm just using a simple slideToggle function of jQuery. It works properly in my
I have the following jQuery code, which works fine: $(document).ready(function () { $('#link1').click(function ()
Using C# .NET 3.5 and WCF, I'm trying to write out some of the
Using C# and System.Data.SqlClient, is there a way to retrieve a list of parameters
I am using toggleClass and slideToggle to accomplish the following: when the user selects

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.