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 :: javascript eventlistener 
Javascript :: two days before in moment 
Javascript :: find vowels in string javascript 
Javascript :: react select 
Javascript :: react router params and render 
Javascript :: inline style to change background color javascript 
Javascript :: duplicate text javascript 
Javascript :: if else statement javascript 
Javascript :: alert library css and js 
Javascript :: javascript record video in browser 
Javascript :: await javascript 
Javascript :: label tag alternative in react native 
Javascript :: sequelize transaction 
Javascript :: multiple elements with same id jquery 
Javascript :: useselector in redux 
Javascript :: javascript addeventlistener pass parameters 
Javascript :: javascript strings are immutable 
Javascript :: ajax returning html instead of json 
Javascript :: JavaScript substring Syntax 
Javascript :: storybook global decorator 
Javascript :: hydration in next js 
Javascript :: make custom draggable in react 
Javascript :: javascript set() method 
Javascript :: detect system dark mode tailwind css 
Javascript :: $(...).Datatables is not a function 
Javascript :: jQuery - AJAX load() Method 
Javascript :: window parent frames javascript 
Javascript :: react query 
Javascript :: js add event listener 
Javascript :: add element in array 
ADD CONTENT
Topic
Content
Source link
Name
2+8 =