Results 1 to 3 of 3

Thread: jQuery Height

  1. #1
    Join Date
    Aug 2007
    Location
    Oakham England
    Posts
    499

    jQuery Height

    Hey,

    I have 4 div's all with '.package h3' they are all different heights. Using jQuery how can I get each height, pick the biggest height and set all the other div.package h3's to the same height...

    Eg..

    div 1 = 100
    div 2 = 110
    div 3 = 230
    div 4 = 60

    The biggest is 230 so sets them all to 230...

    Dan
    Streama - Your WordPress Friend
    http://www.streama.co.uk

  2. #2
    similar to this

    var max_height = 0;
    $('.package).each( function()
    {
    max_height = (max_height == 0 || max_height< $(this).height()) ? $(this).height() : max_height;
    })

    $('.package).height( max_height );

    I did not run , but must work .
    << Please review signature guidelines >>

  3. #3
    Collect the height of all divs, then apply Math.max.
    Code:
    var heights = $('div').map(function() { 
        return parseFloat($(this).height()); 
    });
    
    var max = Math.max.apply(null,heights.toArray());
    $('div').height(max + 'px');
    Here's a JSFiddle.

Similar Threads

  1. Seeking Experienced Jquery/Jquery-UI Coder - Simple project
    By Dub in forum Employment / Job Offers
    Replies: 1
    Last Post: 06-30-2010, 08:20 AM
  2. [JS/CSS] Scrollbar height and content height
    By ic3d in forum Programming Discussion
    Replies: 1
    Last Post: 06-23-2007, 02:42 PM
  3. What's your height!
    By reanncw in forum Web Hosting Lounge
    Replies: 75
    Last Post: 12-19-2004, 12:54 AM
  4. height problem
    By jstrzalko in forum Web Design and Content
    Replies: 5
    Last Post: 11-27-2004, 12:48 PM
  5. Height Problem...
    By jamesyfx in forum Web Design and Content
    Replies: 2
    Last Post: 08-30-2004, 04:18 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •