php75 Posted December 10, 2016 Share Posted December 10, 2016 Can anyone explain this code?.i cant understand this code.... jQuery(window).scroll(function(){ var vscroll=jQuery(this).scrollTop(); jQuery('#text').css( { "transform" :"translate(0px,"+vscroll/2+"px)" }); Quote Link to comment https://forums.phpfreaks.com/topic/302708-jquery-doubt/ Share on other sites More sharing options...
requinix Posted December 10, 2016 Share Posted December 10, 2016 1. .scroll(function) will "bind an event handler to the 'scroll' Javascript event". 2. .scrollTop() will "get the current vertical position of the scroll bar". 3. .css(object) will "set one or more CSS properties". All together, When the window scrolls, get the current scroll position of the window as "vscroll", then set the #text element's "transform" CSS attribute to be translate(0px,vscroll/2 as px). If you're not sure what that means, see it in action. Quote Link to comment https://forums.phpfreaks.com/topic/302708-jquery-doubt/#findComment-1540179 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.