Trigger event when browser scroll bar scrolls
// Trigger event when browser scroll bar scrolls $ (window). Scroll (function() {});
Trigger event when browser window size changes
// Trigger event when browser window size changes $ (window). Resize (function() {});
Listen to all anchor links for smooth movement.
//Listen to all anchor links for smooth movement.$ (' a[href*=#],area[href*=#] '). Click (function() { if(Location.pathname.replace (/^\//, ") = = This. Pathname.replace (/^\//, ') && location.hostname = = This. Hostname) { var$target = $ ( This. hash); $target= $target. Length && $target | | $ (' [name= ' + This. Hash.slice (1) + '] '); if($target. Length) {varTargetoffset =$target. Offset (). Top; //to improve the user experience, make algorithmic improvements to start varClientHeight = Document.body.clientHeight;//Browser Visual HeightTargetoffset = targetoffset-(CLIENTHEIGHT/2) +100;//End$ (' html,body '). Stop (true). Animate ({Scrolltop:targetoffset},1000); return false; } } });
Gets an element based on the distance from the bottom of the current browser window
// gets an element based on the distance from the bottom of the current browser window function Get_element_window_bottom (choose) { ifreturnfalse; = $ (choose) [0].offsettop; = $ (window). scrolltop (); = Mtop- sTop; // add an algorithm to improve user experience Result = result+parseint (DOCUMENT.BODY.CLIENTHEIGHT/2); return result;}
Effect example diagram
The knowledge point record used by jquery to change the status title when scrolling a page to a screen