Dynamically change element height to another

Column A and B
Well, we have two columns A and B. The fact is that column A usually contains more content, so its height is greater (in this case 126px), and column B has less content, so it stays shorter (here 94px). Now I want to make the height B = A, given that the height of column A can be dynamically changed by AJAX, but in order to keep up with column A, the height of column B must also change.
<div id="A">filer text</div> | <div id="B">filler text2</div> Now maybe with jQuery or some js we can get the height of the element with id #A and set it to #B, but the problem is that the content changes dynamically.

+4
source share
2 answers
 $("#a").css("height", $("#b").css("height") ); 

Which then could be included in the callback function, say:

 $.ajax({ ... success:function(msg){ // could be optimized by storing off of the comparision if( $("#a").height() > $("#b").height() ){ $("#b").css("height", $("#a").css("height") ); } } }); 
+6
source

Without jQuery:

 var d = document; d.getElementById("B").style.height = d.getElementById("A").offsetHeight; 
0
source

All Articles