Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

scroll js

// FIXED YOUR NAV ON TOP IF SCROLL

// i listen scroll, and i get if my scroll position Y is superior to 45 px,
//if is superior i fixed my div on top=0, else i can define my div position to relative or none

window.addEventListener('scroll', function() {
    // if scroll down after 45px (position Y)
    if(window.scrollY>45){
        document.querySelector('nav').style.position='fixed'
        document.querySelector('nav').style.top='0'
    }else{
        document.querySelector('nav').style.position='relative'
    }
});
Comment

javascript scroll

// OverflowX and OverflowY properties in Javascript

// x-axis scroll bar

document.getElementById("myId").style.overflowX = "scroll"; 

// y-axis scroll bar 

document.getElementById("myId").style.overflowY = "scroll"; 

// both x-axis and y-axis scroll bar

document.getElementById("myId").style.overflow = "scroll"; 

// To remove overflow, do the following:

document.getElementById("myId").style.overflow = "hidden"; 
Comment

scroll js

window.scroll(x-coord, y-coord)
window.scroll(options)
Comment

PREVIOUS NEXT
Code Example
Javascript :: how to create password generator in react 
Javascript :: accordion reatjs 
Javascript :: Return the highest number in Arrays in JavaScript 
Javascript :: getmonth js 
Javascript :: run javascript in iframe 
Javascript :: like in mongodb 
Javascript :: encode password javascript 
Javascript :: Adding User And Hashed Password In ExpressJS 
Javascript :: js format date 
Javascript :: js reduce 
Javascript :: add and remove class in jquery 
Javascript :: js map array to object 
Javascript :: json to pdf javascript 
Javascript :: how to push mutual array elements in an array nested loop javascript 
Javascript :: every() method 
Javascript :: how to use findoneandupdate 
Javascript :: 2d array includes array js 
Javascript :: change module name react native android studio 
Javascript :: crypto in node js 
Javascript :: push in object javascript 
Javascript :: get browser cookie 
Javascript :: electron ipc from main to renderer 
Javascript :: join in javascript 
Javascript :: alert javascript react native 
Javascript :: how to convert object to array in javascript 
Javascript :: button disable in js 
Javascript :: call a function of another component vue 
Javascript :: shadow class angular 
Javascript :: Random number given a range js 
Javascript :: array.flat 
ADD CONTENT
Topic
Content
Source link
Name
4+1 =