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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T09:59:09+00:00 2026-06-10T09:59:09+00:00

Its getting a bit late so excuse me if I am making a stupid

  • 0

Its getting a bit late so excuse me if I am making a stupid mistake. For some reason the following code:

$(".myClass").each(function(){
    widths[$(this).attr("id")] = $(this).width();   
    if ($(this).attr("id")  != $(clickedExpand).attr("id"))
    {
        $(this).animate({
            width: '10px'
        });
    }

});

The array is initialized as

var widths = new Array();

earlier in the code. For some reason, despite the fact that I am recording the the widths before the animation begins, I am getting post-animation values in the array. It seems as though the animation finishes and then the values get recorded. I have tried to take it out of the function and wrap it in another .each but I am getting the same result.

Any help is would be greatly appreciated!

entire code:

var slateWidths = {};
$(".slateExpand").click(function(){
    var clickedExpand = $(this).closest(".slate");

    $(".slate").each(function(){
        slateWidths[$(this).attr("id")] = $(this).outerWidth();   
        if ($(this).attr("id")  != $(clickedExpand).attr("id"))
        {
            $(this).animate({
                width: '10px'
            });
            $(this).find($('.slateExpand')).hide();
        }

    });

    $(this).text("Restore");
    $(this).removeClass("slateExpand").addClass("slateRestore");
    $(".slateRestore").on("click",function(){

        $(".slate").each(function()
        {
            alert(slateWidths[$(this).attr("id")]);
            //var width = slateWidths[$(this).attr("id")];
            $(this).animate({
                width: slateWidths[$(this).attr("id")]
                });
        });
    });
});
  • 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-10T09:59:10+00:00Added an answer on June 10, 2026 at 9:59 am
    // first of all save all widths for all .slate
    var slateWidths = {};
    $(".slate").each(function(){
        slateWidths[$(this).attr("id")] = $(this).width();
    });
    
    $(".slateExpand").click(function(){
        var $slate = $(this).closest('slate');    
    
        if($slate.hasClass('hidden')) {
    
            $slate.animate({
                width: slateWidths[$slate.attr('id')]
            });
            $(this).text("hide");
            $slate.removeClass("hidden")        
        }else{
    
            $slate.animate({
                width: '10px'
            });
            $(this).text("Restore");
            $slate.addClass("hidden")
        }    
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a bit of code: $('.audio_player embed').each(function() { $(this).attr('wmode','transparent').wrap('<div></div>'); console.log($(this)); }); What this
I have written the following code and getting the below error, I believe its
I've been getting into some assembly lately and its fun as it challenges everything
please try this link for getting my code. its working in all browsers not
How do I automate the process of getting an instance created and its function
Morning/Afternoon guys. Writing some JQuery AJAX shizz and getting a bit stuck. I've got
I am trying to parse a html document using javascript, its getting late and
Im getting the following error in 32 bit machine classic applicationpool Handler PageHandlerFactory-ISAPI-4.0_32bit has
I just included this bit in my already working code, but I am getting
Might be a bit of noob question but it's something that's been getting me

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.