Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Script to match height of 2 divs

Posted on 2007-04-10
2
Medium Priority
?
438 Views
Last Modified: 2012-05-05
I am looking for a piece of script that works onload to check the height of div A, and then sets the height of div B to match
0
Comment
Question by:jarrodprice
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 5

Expert Comment

by:PhilHow
ID: 18886761
Exact code is posted here:

http://snippets.dzone.com/posts/show/3791

I think is written by Coboldinosaur was an expert here at EE once.
0
 
LVL 6

Accepted Solution

by:
ije earned 2000 total points
ID: 18887272
<html>
<head>
<title>IJE Div Leveler</title>
<script type="text/javascript">
window.onload = function(){
  document.getElementById('divB').style.height = document.getElementById('divA').offsetHeight;
}
</script>
</head>
<body>
  <div id="divA" style="height:400px; background-color:#D50000">
    <p>This is div 1</p>
  </div>
  <div id="divB" style="background-color:#8ECEFB">
    <p>This is div 2</p>
  </div>
</body>
</html>
0

Featured Post

The top UI technologies you need to be aware of

An important part of the job as a front-end developer is to stay up to date and in contact with new tools, trends and workflows. That’s why you cannot miss this upcoming webinar to explore the latest trends in UI technologies!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
JavaScript has plenty of pieces of code people often just copy/paste from somewhere but never quite fully understand. Self-Executing functions are just one good example that I'll try to demystify here.
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

670 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question