Get a div height that dynamically changes the height

EXAMPLE: http://jsbin.com/ewiko4/5/

So, I have some dynamic divs that I need to figure out when they change. I can get the height when the document is loading, but it will not be updated.

In the example, I added a larger button, but irl will be changed via jq and ajax

Yup, I cannot add a callback to the animation button because it will not be there.

+3
source share
3 answers

Check out this edit of your jsbin.

A couple of changes:

  • Your window events can be tied at the same time $(window).bind('load resize', resizeFrame)

  • resizeFrame , , ...

  • , ( ), setInterval .


setInterval(resizeFrame, 150);

resizeFrame 150 . , , , ...

+1

, , externalHeight():

$('#makeBigger').click(function(){
  $('#buyNow').animate({
        height: '+=10px'
  }, function() {
    var newHeight = $('#buyNow').outerHeight();
    // ...
  })
});

animate() , , , . , . <div> , , ajax.

+3

var h = $('#content').height();

var h = 500;
$('#content').height(h);

http://api.jquery.com/height/

, MultiView. , XXX.height(). ASP, .

0

Source: https://habr.com/ru/post/1763982/


All Articles