jQuery dynamically change element height

前端 未结 4 2063
滥情空心
滥情空心 2021-01-04 20:01

I\'m working on a fluid layout project. I have some fixed height DIVs in my document, and the heights are different for all of them. I need to proportionally change these DI

4条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-04 20:19

    use .data to store the initial size of the div inside your $.each function

    $(this).data('height', $(this).height());
    $(this).data('width', $(this).width());
    

    you can later retrieve the old sizes within the resize callback

    var old_height = $(this).data('height');
    var old_width = $(this).data('width');
    

    Hope this helps

提交回复
热议问题