change group elements size

Discussion in 'JavaScript' started by yonip, Apr 10, 2011.

  1. #1
    Hi,
    I have some same divs' that each contains 2 divs. I want the main div's width will be 90%, one of the sub-divs width will adapt content, and the other sub-div will fill the difference. Because the size is in precents, I need change him in window resize.
    I need to do that for 10 divs like this. The sub-div content is not the same in all divs.
    I know I can do that in javascript like this:
    document.getElementById('id').style.width=((0.9*document.width)-50)+'px';
    but I don't know how do that for all divs (and dont for specific id), and how replace the number "50" to the width of the compatible sub-div.

    TIA
     
    yonip, Apr 10, 2011 IP
  2. codeartist

    codeartist Peon

    Messages:
    96
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    are you using jquery ? if yes do something like this

    $('#parent_id .childdivclass').each(function(index) {
    alert(index + ': ' + $(this).text());
    });
     
    codeartist, Apr 15, 2011 IP