How do I use the orientationchange in jQuery Mobile when working with height?

Posted by stucktryingtofigurethisout on Stack Overflow See other posts from Stack Overflow or by stucktryingtofigurethisout
Published on 2011-09-17T17:43:48Z Indexed on 2012/09/28 15:38 UTC
Read the original article Hit count: 177

Filed under:
|

In jQuery Mobile, I am trying to adjust the height of an image to the height of the window. The height of the window depends on the orientation of the device, but I found out that whenever I change the orientation, the height of the window that is plugged into the expressions for the height of the image is the height of the window BEFORE the orientation change! So, how do I make it so it picks up the height of the window AFTER the orientation change and then uses this new value to adjust the image height?

For the code I have

$(window).bind('orientationchange',function(e){
  if(window.orientation == 0)
  {
    $('img').css('width') = $(window).height()*.5;
  }
  else
  {
    $('img').css('width') = $(window).height()*.6;
  }
});

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about mobile