Orientation change handler

Function changes style of objects inside html while orientation of screen is changed.
/* Files which should be implemented into html
<script src="http://code.jquery.com/jquery-1.11.3.min.js"></script>
<script src="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"> */

$(document).on("pagecreate",function(event){
  $(window).on("orientationchange",function(){
    if(window.orientation == 0)
    {
        // portrait orientation handler, there is change of styles
      $("div").css({"width":"300px","height":"200px"});
    }
    else
    {
        // landscape orientation handler, there is change of styles
      $("div").css({"width":"200px","height":"400px"});
    }
  });                   
});

Responses

0 Replies