Solved

Script to match height of 2 divs

Posted on 2007-04-10
2
436 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 500 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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

729 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