Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

add class on window scroll

$(window).scroll(function() {    
    var scroll = $(window).scrollTop();

     //>=, not <=
    if (scroll >= 500) {
        //clearHeader, not clearheader - caps H
        $(".clearHeader").addClass("darkHeader");
    }
}); //missing );
Comment

add class in element on scroll

const [scroll, setScroll] = useState(false);
 useEffect(() => {
   window.addEventListener("scroll", () => {
     setScroll(window.scrollY > 50);
   });
 }, []);
Comment

add class in element on scroll

className={scroll ? "bg-black" : "bg-white"}
Comment

PREVIOUS NEXT
Code Example
Javascript :: react js pdf generate from html 
Javascript :: user icon discord js 
Javascript :: js remove form object by key 
Javascript :: window.location.href url.action parameters 
Javascript :: javascript filter array of objects by array 
Javascript :: sentry ignoreerrors 
Javascript :: string to array angular 
Javascript :: jquery not readonly 
Javascript :: javascript is url 
Javascript :: npm config proxy 
Javascript :: spining load react component 
Javascript :: js - change div height on scroll 
Javascript :: useref reactjs 
Javascript :: settimeout javascript 
Javascript :: htpp status 
Javascript :: disable VirtualizedLists should never be nested inside 
Javascript :: javascript hello 
Javascript :: jquery input hidden value 
Javascript :: MAC addresses in JavaScript 
Javascript :: .env.development.local 
Javascript :: how to show selected value in select box using jquery 
Javascript :: how to kill all node processes 
Javascript :: firebase admin delete user 
Javascript :: leaflet control zoom on scrolling page 
Javascript :: how to use js console log 
Javascript :: how to convert string to snake case in javascript 
Javascript :: Scroll elementleft using js 
Javascript :: find smallest number in array javascript using for loop 
Javascript :: class function 
Javascript :: json full form 
ADD CONTENT
Topic
Content
Source link
Name
7+3 =