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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T19:33:32+00:00 2026-05-27T19:33:32+00:00

i have the following function written in javascript which operate a slide up/down box.

  • 0

i have the following function written in javascript which operate a slide up/down box. but in firefox, it malfunctions. it just opens/closes once. after that no play.
i am getting the height() param from the box and storing it in hidden input. but firefox is unable to read the correct height of the box.

look at the code to understand better :

JS :

function boxCollapse() {
    $("#boxHeight").attr("value", parseInt($("#accTipsBox").height()));
    $("#accTipsBox").animate({height:'0px'});
    $(".btnCollapse").css({display:'none'});
    $(".btnExpand").css({display:'block'});
    $("#accTipsBox").css({padding:'0px'});
}

function boxExpand() {
    $("#accTipsBox").animate({height: $("#boxHeight").attr("value")});
    $(".btnExpand").css({display:'none'});
    $(".btnCollapse").css({display:'block'});
    $("#accTipsBox").css({padding:'0px'});
}

HTML :

<section class="accBox grey">
    <header>
        <div class="title">DISCLAIMERS</div>
        <a style="display: none;" class="btnExpand" href="javascript:void(0);"><img src="/resources/images/boxExpandGrey.jpg" alt="button"></a>
        <a style="display: block;" class="btnCollapse" href="javascript:void(0);"><img src="/resources/images/boxCollapseGrey.jpg" alt="button"></a>
    </header>
    <div id="accTipsBox" style="height: 125px; padding: 0px;">
        <input type="hidden" id="boxHeight" value="125">    
        <div class="accBoxContent">
            <div><p></p><p></p><p></p></div>
        </div>
    </div>
</section>
  • 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-27T19:33:32+00:00Added an answer on May 27, 2026 at 7:33 pm

    I think this is what you were going for:

    //bind a `click` event handler to all the elements with the `btnExpandCollapse` class
    $('.btnExpandCollapse').on('click', function (event) {
    
        //stop the default behavior of clicking the link (stop the browser from scrolling to the top of the page)
        event.preventDefault();
    
        //first select the parent of this element (`header` tag) and then get its sibling element that has the `accTipsBox` class, then take that element and slide it up or down depending on its current state
        $(this).parent().siblings('.accTipsBox').slideToggle(500);
    });
    

    With some slight tweaks to your HTML:

    <section class="accBox grey">
        <header>
            <div class="title">DISCLAIMERS</div>
    
            <!-- Notice there is only one link now that does the job of both -->
            <a class="btnExpandCollapse" href="#"><img src="/resources/images/boxExpandGrey.jpg" alt="button"></a>
        </header>
    
        <!-- Notice I changed the ID attribute to CLASS so this code will work for repeated structure -->
        <div class="accTipsBox" style="height: 125px; padding: 0px;">  
            <div class="accBoxContent">
                <div>
                    <p>1</p>
                    <p>2</p>
                    <p>3</p>
                </div>
            </div>
        </div>
    </section>
    

    Here is a demo: http://jsfiddle.net/VGN64/

    Here is some documentation:

    • .slideToggle(): http://api.jquery.com/slidetoggle
    • .siblings(): http://api.jquery.com/siblings

    On a side-note, if you want to store data about a DOM element, use jQuery’s $.data() method:

    var $box = $("#accTipsBox");
    $.data($box[0], 'height', $box.height());
    

    You can then access this data like this

    var height = $.data($('#accTipsBox')[0], 'height');
    

    Notice that I appended [0] onto the end of the jQuery object to return just the DOM node associated with the object, this is required by the $.data() method: http://api.jquery.com/jquery.data. This is a very fast method of storing data associated with DOM elements.

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

Sidebar

Related Questions

I have written the following function but it's isn't returning anything when I run
I have written following function which checks whether start_date field is not empty and
Friends, I have written the following JavaScript to ascertain which row of an tabular
I have found the following script which is apparently written using the javascript framework
I Have the following function. function ChangeDasPanel(controllerPath, postParams) { $.post(controllerPath, postParams, function(returnValue) { $('#DasSpace').hide(slide,
I have the following function written to randomly pick a file from a directory.
If you look at http://www.danfarrellwright.com/screwsline/front_end/product.php?product_id=104 I have written the following function to add the
I have a function written in javascript and I'd like to know how, if
I have written a HTML page which has following code. <div id=adsListContainer style=margin: 5px;>
I have the following php function which i wrote a while ago. Now however,

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.