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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T15:03:25+00:00 2026-05-25T15:03:25+00:00

I have following script: var height = 0; $(‘.scroller’).each(function() { $(this).children(‘div’).each(function() { if (height

  • 0

I have following script:

var height = 0;
$('.scroller').each(function() {

    $(this).children('div').each(function() {

        if (height < $(this).height()) {
            height = $(this).height();
        }

    });
    $(this).css("height", height + "px");

});

What it does:

  • loop through each children div inside each .scroller div
  • height < $(this).height() = if height of the currently looped div is bigger than 0 it is setting the height of this div as new value of the height variable
  • this way is finding the highest div element in each .scroller div
  • than, the height (height of the highest element ) is set to .scroller div

The issue:

  • if any element inside first ‘.scroller’ is higher than ANY element in the second .scroller it is setting the height (highest element in first .scroller) also to second scroller – example: http://jsfiddle.net/MrTest/7jAAG/20/

Is element in the first .scroller are not higher than elements in second .scroller everything works fine – example: http://jsfiddle.net/MrTest/7jAAG/16/

I think the problem is setting the height var – how can I reset this value to 0 BEFORE going to loop though second .scroller ?

  • 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-25T15:03:26+00:00Added an answer on May 25, 2026 at 3:03 pm

    I may be misunderstanding but could you not just do this:

    $('.scroller').each(function() {
        var height = 0;
        $(this).children('div').each(function() {
    
            if (height < $(this).height()) {
                height = $(this).height();
            }
    
        });
        $(this).css("height", height + "px");
    
    });
    

    the height variable will then get reset for each instance of .scroller in the DOM that’s looped through.

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

Sidebar

Related Questions

Hi I have the following script in my form function pdf() { var frm
I have the following script: Timer=0; function countdown(auctionid){ var auctions; var divs; Timer=Timer+1; if((Timer%10==0)||(Timer==1)){
I have put together the following mootools script window.addEvent('domready', function() { var shouts =
I have the following: $(document).ready(function() { var myIframe = document.getElementById('myIframe'); var element = myIframe.contentDocument.createElement('script');
I have the following HTML / JS: <html> <body> <script> function foo(){ var html
I have the following piece of HTML: <style type=text/css> #c{width:200px;height:500px} </style> <canvas id=c></canvas> <script
I have the following script that changes my image on a timer: var da
I have the following MXML: <mx:Script> var someBoolean:Boolean = determineSomeCondition(); </mx:Script> .... <foo:MyComponent somePropertyExpectingIDataRenderer={
hi i have following code in this i have div card-208 on click i
I have this fragment that demonstrates the problem: <html> <head> <title>height query demo</title> <script

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.