Hi Guys,
I am new to JQuery. Just started working with it last night. I need help. I need to center a div vertically, and I can't figure out how to do that.
I am trying to get the height of the image dynamically, but when I use console.log() to view the value it always returns a value of 0. How do I fix this issue? I have inserted the code below:
$(function(){ var ScreenHeight = $(window).height(); var ImageHeight = $('#bkgImages').height(); var ImageMove = (ScreenHeight-ImageHeight)/2 $('#wrapper').slideDown(500); $('#bkgScreen').animate({opacity: .5}, 700); $('#bkgImages').css({top: "-" + ImageMove + "px"}); console.log(ImageHeight); });
Also, this value gets calculated only once during a session, and I need it to check the value every time a user changes the window size. How do I do that?
Any help would be appreciated.
Thanks guys.