Set Div Height to Another Div Height

I know similar questions have been asked and I have referenced them, but have yet to get this to work. I have an aside that may not have as much content as the main section next to it. I am using the load event window.load to run my script called asideHeightSet below is the snippet that calls it:

  <script>
    window.onload=function(){

        asideHeightSet("main_content_aside", "main_content_section");
    }
  </script>

I have other functions that are executing fine from there and this snippet is after I can any dependent jQuery libraries. My javascript for the asideHeightSet is:

var $ = function (id) { return document.getElementById(id); }
function asideHeightSet(aside, section){
var sectionHeight = $(section).style.height;
$(aside).style.height= sectionHeight;

}

I ran the firebug debugger in firefox and it keeps on showing that the height of the section is blank it outputs "" in the watch when I step through.

Any help would be appreciated.

Thx


This did it for me:

function asideHeightSet(aside, section){ var sectionHeight = $(section).offsetHeight-22;

$(aside).style.height = sectionHeight+"px";

}

the 22 was to take into account for padding and border of aside.

Answers


Running the code you provided lets me get the height of the elements with

$(section).offsetHeight

style height returns none because probably there are no height css style associated with the element. Try it and tell me what the results are.


Need Your Help

Date minus date query

sql sql-server date

I have a query like shown below and I want to make calculation for end_scan-packing_date column, how can I achieve this?

WCF TLS cipher suite

.net wcf security

I have a requirement to specify the cipher suite to be used for transport level security on a

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.