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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T08:02:06+00:00 2026-06-13T08:02:06+00:00

This fiddle http://jsfiddle.net/paultrotter50/fdvC5/ shows the problem I am having with detecting the height of

  • 0

This fiddle http://jsfiddle.net/paultrotter50/fdvC5/ shows the problem I am having with detecting the height of position absolute content.

I am creating a tabbed panel so users can choose a room type and then a room sub-type. The room subtypes (ul.sub-types) have a position of absolute so they can be positioned correctly.

When the user switches between room sub-types I need to use jQuery/javascript to detect the height of the ul.sub-types so that I can set the height of the whole panel (div.tab-panel – shown with a blue outline) to match its contents. This should mean the page content coming after the panel does not get overlapped by the absolutely positioned room subtypes.

Unfortunately the jQuery function seems to run twice – the first time it detects the correct value and adjusts the blue outlined tab-panel correctly. Then it immediately seems to run again and returns an incorrect value.

You can see this most clearly when you click on family in the left hand column and then the bottom Family Double on the right hand side. This has lots of items in the list so that the height change is emphasized.

Any advice on what is causing the problem and/or how to fix this would be greatly appreciated.

HTML:

<section id="main_col">

<div class="tab-panel">

                                <ul id="room-types" class="left-tabs">

                                    <li class="type double selected">
                                        <input id="double" type="radio" name="room-type" checked="checked">
                                        <label for="double">Double

                                        <ul class="sub-types">

                                            <li class="selected">
                                                <input id="subtype1" type="radio" name="double-subtypes" value="subtype1" checked="checked">
                                            <label for="subtype1">

                                                <span class="col2">
                                                   <img src="img/pg-specific/left_col/room_sea_view.jpg" alt=" "> 
                                                </span><!-- end col2 -->

                                                <span class="col1">
                                                    <span class="title">Classic Double</span>
                                                    <ul>
                                                        <li>bullet item 1</li>
                                                        <li>bullet item 2</li>
                                                        <li>bullet item 3</li>
                                                    </ul>
                                                </span><!-- end col1 -->
                                                <span class="clearfix"></span>
                                            </label><!-- end lable for subtype1 -->
                                         </li>


                                        <li>
                                            <input id="subtype2" type="radio" name="double-subtypes" value="subtype2">
                                            <label for="subtype2">

                                                <span class="col2">
                                                   <img src="img/pg-specific/left_col/room_sea_view.jpg" width="124" height="70" alt=" "> 
                                                </span><!-- end col2 -->

                                                <span class="col1">
                                                    <span class="title">Classic Double</span>
                                                    <ul>
                                                        <li>bullet item 1</li>
                                                        <li>bullet item 2</li>
                                                        <li>bullet item 3</li>
                                                    </ul>
                                                </span><!-- end col1 -->
                                                <span class="clearfix"></span>
                                            </label><!-- end lable for subtype2 -->
                                         </li>

                                         <li>
                                            <input id="subtype3" type="radio" name="double-subtypes" value="subtype3">
                                            <label for="subtype3">

                                                <span class="col2">
                                                   <img src="img/pg-specific/left_col/room_sea_view.jpg" width="124" height="70" alt=" "> 
                                                </span><!-- end col2 -->

                                                <span class="col1">
                                                    <span class="title">Classic Double</span>
                                                    <ul>
                                                        <li>bullet item 1</li>
                                                        <li>bullet item 2</li>
                                                        <li>bullet item 3</li>
                                                    </ul>
                                                </span><!-- end col1 -->
                                                <span class="clearfix"></span>
                                            </label><!-- end lable for subtype3 -->
                                         </li>
                                     </ul>
                                     </label>
                                </li><!-- end .type.double -->


                                <li class="type twin">
                                    <input id="twin" type="radio" name="room-type">
                                    <label for="twin">Twin

                                    <ul class="sub-types">

                                        <li class="selected">
                                            <input id="subtype1" type="radio" name="twin-subtypes" value="subtype1" checked="checked">
                                            <label for="subtype1">

                                                <span class="col2">
                                                   <img src="img/pg-specific/left_col/room_sea_view.jpg" width="124" height="70" alt=" "> 
                                                </span><!-- end col2 -->

                                                <span class="col1">
                                                    <span class="title">Twin Double</span>
                                                    <ul>
                                                        <li>bullet item 1</li>
                                                        <li>bullet item 2</li>
                                                        <li>bullet item 3</li>
                                                    </ul>
                                                </span><!-- end col1 -->
                                                <span class="clearfix"></span>
                                            </label><!-- end lable for subtype1 -->
                                         </li>

                                        <li>
                                            <input id="subtype2" type="radio" name="twin-subtypes" value="subtype2">
                                            <label for="subtype2">

                                                <span class="col2">
                                                   <img src="img/pg-specific/left_col/room_sea_view.jpg" width="124" height="70" alt=" "> 
                                                </span><!-- end col2 -->

                                                <span class="col1">
                                                    <span class="title">Twin Double</span>
                                                    <ul>
                                                        <li>bullet item 1</li>
                                                        <li>bullet item 2</li>
                                                        <li>bullet item 3</li>
                                                    </ul>
                                                </span><!-- end col1 -->
                                                <span class="clearfix"></span>
                                            </label><!-- end lable for subtype2 -->
                                         </li>

                                         <li>
                                            <input id="subtype3" type="radio" name="twin-subtypes" value="subtype2">
                                            <label for="subtype3">

                                                <span class="col2">
                                                   <img src="img/pg-specific/left_col/room_sea_view.jpg" width="124" height="70" alt=" "> 
                                                </span><!-- end col2 -->

                                                <span class="col1">
                                                    <span class="title">Twin Double</span>
                                                    <ul>
                                                        <li>bullet item 1</li>
                                                        <li>bullet item 2</li>
                                                        <li>bullet item 3</li>
                                                    </ul>
                                                </span><!-- end col1 -->
                                                <span class="clearfix"></span>
                                            </label><!-- end lable for subtype3 -->
                                         </li>
                                     </ul>
                                     </label>
                                </li><!-- end .type.twin -->


                                <li class="type family">
                                    <input id="family" type="radio" name="room-type">
                                    <label for="family">Family

                                    <ul class="sub-types">

                                        <li class="selected">
                                            <input id="subtype1" type="radio" name="family-subtypes" value="subtype1" checked="checked">
                                            <label for="subtype1">

                                                <span class="col2">
                                                   <img src="img/pg-specific/left_col/room_sea_view.jpg" width="124" height="70" alt=" "> 
                                                </span><!-- end col2 -->

                                                <span class="col1">
                                                    <span class="title">Family Double</span>
                                                    <ul>
                                                        <li>bullet item 1</li>
                                                        <li>bullet item 2</li>
                                                        <li>bullet item 3</li>
                                                    </ul>
                                                </span><!-- end col1 -->
                                                <span class="clearfix"></span>
                                            </label><!-- end lable for subtype1 -->
                                         </li>

                                        <li>
                                            <input id="subtype2" type="radio" name="family-subtypes" value="subtype2">
                                            <label for="subtype2">

                                                <span class="col2">
                                                   <img src="img/pg-specific/left_col/room_sea_view.jpg" width="124" height="70" alt=" "> 
                                                </span><!-- end col2 -->

                                                <span class="col1">
                                                    <span class="title">Family Double</span>
                                                    <ul>
                                                        <li>bullet item 1</li>
                                                        <li>bullet item 2</li>
                                                        <li>bullet item 3</li>
                                                    </ul>
                                                </span><!-- end col1 -->
                                                <span class="clearfix"></span>
                                            </label><!-- end lable for subtype2 -->
                                         </li>

                                         <li>
                                            <input id="subtype3" type="radio" name="family-subtypes" value="subtype3">
                                            <label for="subtype3">

                                                <span class="col2">
                                                   <img src="img/pg-specific/left_col/room_sea_view.jpg" width="124" height="70" alt=" "> 
                                                </span><!-- end col2 -->

                                                <span class="col1">
                                                    <span class="title">Family Double</span>
                                                    <ul>
                                                        <li>bullet item 1</li>
                                                        <li>bullet item 2</li>
                                                        <li>bullet item 3</li>
                                                        <li>bullet item 1</li>
                                                        <li>bullet item 2</li>
                                                        <li>bullet item 3</li>
                                                        <li>bullet item 1</li>
                                                        <li>bullet item 2</li>
                                                        <li>bullet item 3</li>
                                                        <li>bullet item 1</li>
                                                        <li>bullet item 2</li>
                                                        <li>bullet item 3</li>
                                                        <li>bullet item 1</li>
                                                        <li>bullet item 2</li>
                                                        <li>bullet item 3</li>
                                                        <li>bullet item 1</li>
                                                        <li>bullet item 2</li>
                                                        <li>bullet item 3</li>
                                                    </ul>
                                                </span><!-- end col1 -->
                                                <span class="clearfix"></span>
                                            </label><!-- end lable for subtype3 -->
                                         </li>
                                     </ul>
                                     </label>
                                </li><!-- end .type.family -->


                            </ul>
                        </div>

​
CSS:

/*--- booking tab panels --- */

                    .tab-panel ul.sub-types {display:none;}
                    .tab-panel { position:relative; width:100%; border: 1px solid blue; height:500px; font-size:0.9em;}
                    .tab-panel input[type="radio"]:checked + label ul.sub-types {display:block; position:absolute; right:0px; top:0px; width:80%;}
                    .tab-panel ul.sub-types > li .col2, .tab-panel ul.sub-types > li .col1 ul  {display:none;}
                    .tab-panel ul.sub-types input[type="radio"]:checked  + label .col2, .tab-panel ul.sub-types input[type="radio"]:checked + label .col1 ul  {display:block;}
                    #main_col .tab-panel input, #main_col .tab-panel label {float:left;}
                    #main_col .tab-panel input {clear:both; margin-right:10px; width:auto;}
                    #room-types > li > input[type="radio"]:checked + label { font-weight:bold; background-color: #bfb2b5; width:60%; }
                    #room-types > li > input[type="radio"]:checked + label .sub-types { font-weight:normal;}
                    #room-types > li > label {padding:7px 0px 5px 5px;}
                    .tab-panel .sub-types {background-color: #e0d7c1; }

                    .tab-panel .col1, .tab-panel .col2 {display:block;}
                    .tab-panel .col1 {float:left; width:58%; margin-left:10%; margin-top:10px; margin-right:0px;}
                    .tab-panel .col2 {float:right; width:25%; padding:10px; margin-right:0px;}
                    .tab-panel .sub-types li.selected label {width:100%;}
                    .tab-panel .sub-types li.selected  label { background-color:#f3ebde;}
                    .tab-panel .sub-types input[type="radio"]:checked + label {background-color:#f3ebde; background-image: url(../img/core/radio-on-cream-bg.gif); background-repeat:no-repeat; background-position:7px 13px; cursor:auto;}
                    .tab-panel .sub-types li label  {background: url(../img/core/radio-off-sand-bg.gif); background-repeat:no-repeat; background-position:7px 13px; cursor:pointer; }
                    #main_col .tab-panel .sub-types li label {margin-bottom:0px; padding-bottom:10px; padding-top:5px;}
                    .tab-panel .sub-types li label li {background-image:url("../img/core/tick-description-text.gif"); background-repeat:no-repeat; background-position: 0px 2px; padding-left:15px; width: 100px; float: left; margin-right:15px; margin-bottom:3px;}
                    .tab-panel .sub-types li label ul {width:100%; float:left; margin-top:8px;} 
                    .tab-panel .sub-types li label img {max-width: 100%; height: auto;}
                    .tab-panel .sub-types input[type="radio"]:checked + label .title { font-weight:bold;}​

jQuery:

$(document).ready(function() {

/* book page panels -------------------------------------- */


$('.sub-types li').click(function() {
    $(this).parent().find('input:radio').attr('checked', false)
    $(this).children('input:radio').attr('checked', true)
    $('.sub-types li').removeClass('selected');
    $(this).addClass('selected');

    var panelHeight = $(this).closest('ul.sub-types').height();
    alert("height: " + panelHeight);
    $(this).closest(".tab-panel").css('height', panelHeight)

});

}); /* end $(document).ready(function() */​
  • 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-13T08:02:07+00:00Added an answer on June 13, 2026 at 8:02 am

    Ok, so the reason it’s getting run twice is that your hidden elements underneath are also being clicked. Try specifying a :visible selector. I also had to switch the click event to On, and bind it to a different dom element otherwise the click event would bind only to whichever element was marked as ‘li:visible’ at document.ready:

    $('.sub-types').on('click', 'li:visible', function() {
        $(this).parent().find('input:radio').attr('checked', false)
        $(this).children('input:radio').attr('checked', true)
        $('.sub-types li').removeClass('selected');
        $(this).addClass('selected');
    
        var panelHeight = $(this).closest('ul.sub-types').height();
        alert("height: " + panelHeight);
        $(this).closest(".tab-panel").css('height', panelHeight)
    
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

http://jsfiddle.net/9aaNh/ Please check this Fiddle. I am having problem with spacing in between text
I have isolated my problem in this fiddle http://jsfiddle.net/xYphz/ It uses the root model
Ok, I have this fiddle http://jsfiddle.net/25J3M/6/ , I want to position the red and
Please take a look at this fiddle: http://jsfiddle.net/d3uc9/4/ I have a problem with this,
In this fiddle http://jsfiddle.net/dAHqe/2/ I've created examples for the 2 main uses (that I've
Referencing this Fiddle ( http://jsfiddle.net/j5uGN ), how can I toggle a clicked image's border
I have this fiddle: http://jsfiddle.net/yub2B/4/ HTML: <input type=text /> <input type=text /> <input type=text
I have this fiddle : http://jsfiddle.net/XjeCf/1/ that works like I want and this one
look at this fiddle: http://jsfiddle.net/ugxNK/ I want that the first list element is in
Please look at this fiddle: http://jsfiddle.net/dyv88/16/ On IE7, if I put width: 100% on

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.