JQuery to Find window Height

JQuery to set div in center of screen:

 The following code is used to find the center position of the any size of the screen. here i set the div in center of the screen using jquery.

  “$(window).height()” this function is used to get hight of the window(Screen).

var divCenter= $(‘#div_id’);
divCenter.css(“top”, ($(window).height() – divCenter.height())/2  + ‘px’);

You can change this code whatever you find like screen height, width etc.

Leave a Reply

Your email address will not be published. Required fields are marked *