Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

js - change div height on scroll

var header = document.getElementById("header_parent");

window.onscroll = function(e) {
    if(window.scrollY) {
        if(window.pageYOffset > 50) {
            header.style.height = 30;
        } else {
            header.style.height = 50;
        }
    }
}
Comment

change height of div with scroll in javascript

$(window).on('scroll', function () {
    var scrollTop = $(window).scrollTop();
    if (scrollTop > 50) {
        $('#header_parent').stop().animate({height: "30px"},200);
    }
    else {
         $('#header_parent').stop().animate({height: "50px"},200);   
    }
});
Comment

PREVIOUS NEXT
Code Example
Javascript :: react native build android 
Javascript :: react electron boilerplate 
Javascript :: javascript splice 
Javascript :: javascript get query params from url 
Javascript :: how to filter an array by list of objects in javascript 
Javascript :: ionic capacitor splash screen spinner 
Javascript :: create loop to specific length react 
Javascript :: round innerhtml value up javascript 
Javascript :: iso 8601 date to Js date 
Javascript :: how to counts date from moment js 
Javascript :: xpath nodejs 
Javascript :: How to Close a React Native Modal with a Button 
Javascript :: jquery select dropdown 
Javascript :: eslint disable tag 
Javascript :: node.js name of file 
Javascript :: new promise function 
Javascript :: update photoURL firebase 
Javascript :: javascript image to blob 
Javascript :: jquery with npm in laravel 
Javascript :: jquery find tag and class 
Javascript :: tsconfig build only files and not src 
Javascript :: chrome console angular scope 
Javascript :: Check for a Null or Empty String in JavaScript 
Javascript :: javascript function length 
Javascript :: react select and react hook form 
Javascript :: js concat string 
Javascript :: what is last index of array 
Javascript :: classlist 
Javascript :: window.addEventListener("online"); 
Javascript :: javascript check if string contains only numbers 
ADD CONTENT
Topic
Content
Source link
Name
7+5 =