开发者

jQuery to set the height of a div to match the one next to it

I've got two divs (#mosaicBlog and #mosaicAside). I've got #mosaicAside's CSS set to overflow hidden and want to set #mosaicAside to always be the height of #mosaicBlog (dynamic height page to page).

I thought this would work, but it does not seem to be working. I'm thinking it may just be a syntax problem.

$(function(){
    var curHeight = parseInt($("#mosaicBlog").height());
        newHeight = Math.ceil(curHeight/开发者_开发技巧189) * 189 - 7;
            alert(newHeight );
    $("#blogAside").height(newHeight);
});

Any help would be appreciated.


Use $(function(){ instead of $({

http://jsbin.com/uzera7/edit


try after loading document

$(document).ready( function() {
    var curHeight = parseInt($("#mosaicBlog").height()),
     newHeight = Math.ceil(curHeight/189) * 189 - 5;
     $("#blogAside").height(newHeight );
});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜