Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

sticky operations in javascript

var siteHeader = document.getElementById('siteHeader'),
    siteNav = document.getElementById('siteNav');

    window.onscroll = function() {
        if ( siteNav.offsetTop < document.documentElement.scrollTop + 26 || siteNav.offsetTop < document.body.scrollTop + 26) {
            siteHeader.setAttribute("class","sticky");
        }
        else {
            siteHeader.setAttribute("class","");
        }
    }
Comment

PREVIOUS NEXT
Code Example
Javascript :: references another schema in sequelize 
Javascript :: node http post 
Javascript :: unexpected token. did you mean `{'}` or `&amp;gt;`? react 
Javascript :: jquery test div exists 
Javascript :: textbox text change jquery 
Javascript :: install electron 
Javascript :: js go back 
Javascript :: jquery delay to call function 
Javascript :: div onchange react 
Javascript :: react-native-paper resize switch resize 
Javascript :: loopback get relationship in before save 
Javascript :: hnazmul 
Javascript :: classlist add js to add more than one class 
Javascript :: split string into equal chunks javascript 
Javascript :: get json by id 
Javascript :: auto clicker for cookie clicker 2 
Javascript :: console log returns object object 
Javascript :: jquery setinterval clear after first attempt 
Javascript :: query selector by href 
Javascript :: generate unique id javascript 
Javascript :: axios upload progress react 
Javascript :: delete list of keys from object javascript 
Javascript :: pangram javascript 
Javascript :: navigate to another page in javascript 
Javascript :: change word in string javascript 
Javascript :: how to start react project 
Javascript :: component unmount useeffect 
Javascript :: js when key is pressed 
Javascript :: check if string is valid date 
Javascript :: angular adding delay 
ADD CONTENT
Topic
Content
Source link
Name
8+5 =