I have some elements on my website that need to be updated every time page is being scrolled or resized. So I made a small jQuery code to do that.
$(window).scroll(function(){
setSlideshowButtons();
});
$(window).resize(function() {
setSlideshowButtons();
});
function setSlideshowButtons() {
var size = $(".slides img").height();
$(".navigation_buttons").css("margin-top", "-" + size/2 + "px");
}
And so far everything worked great. But than I found out that I also have to set those properties on document load. So I also put this in the document.ready function.
$(document).ready(function(){
setSlideshowButtons();
});
But it doesn't seem to work. But when I scroll or resize the window, function runs itself and CSS properties change.