Sur*_*raj 4 html javascript css jquery

在这里,我们有两列A和B.事情是列A通常包含更多内容,因此其高度更高(在这种情况下为126px),列B具有更少的内容,因此它保持更短(此处为94px).现在我想确定B = A的高度,考虑到A列的高度可能会由AJAX动态改变,但为了与A列保持同步,B列的高度也必须改变.
<div id="A">filer text</div>| <div id="B">filler text2</div>
现在可以通过使用jQuery或一些js我们可以获得id为#A的元素的高度并将其设置为#B但问题在于内容动态变化.
$("#a").css("height", $("#b").css("height") );
Run Code Online (Sandbox Code Playgroud)
然后可以将其置于回调函数中,例如:
$.ajax({
...
success:function(msg){
// could be optimized by storing off of the comparision
if( $("#a").height() > $("#b").height() ){
$("#b").css("height", $("#a").css("height") );
}
}
});
Run Code Online (Sandbox Code Playgroud)