Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

if element touches another element on scroll

$(window).scroll(function() {
    var div1 = $("#div1");
    var div2 = $("#div2");
    var div1_top = div1.offset().top;
    var div2_top = div2.offset().top;
    var div1_bottom = div1_top + div1.height();
    var div2_bottom = div2_top + div2.height();

    if (div1_bottom >= div2_top && div1_top < div2_bottom) {
        // overlapped
    }
});​
Comment

PREVIOUS NEXT
Code Example
Javascript :: powershell json check if property exists 
Javascript :: How to use Node.js Path 
Javascript :: convert utc time to specific timezone javascript 
Javascript :: how to enable button of upload after click on chosefile in jquery 
Javascript :: parallel and sequential implementation with asyn await javascript 
Javascript :: livewire afterDomUpdate 
Javascript :: How to Create a “Sticky” Floating Footer Bar in WordPress 
Javascript :: usecase of async/await 
Javascript :: dynamic operator javascript if statement 
Javascript :: Get value from ionRangeSlider in jquery 
Javascript :: html make tooltip avaible if text overflow 
Javascript :: how to make model class for complex json in flutter 
Javascript :: javascript verbatim string 
Javascript :: flatpicker js init 
Javascript :: Javascript highest to lowest 
Javascript :: reply nodejs terminal 
Javascript :: button color change loop in react 
Javascript :: Get mimeType in Javascript 
Javascript :: loadash pick property from object by different name 
Javascript :: limpar html string js 
Javascript :: multiple js files vuejs 
Javascript :: Grad points by javascript switch 
Javascript :: $("#right-button").click(function() { event.preventDefault(); $(".table-responsive").animate( { scrollLeft: "+=300px" }, "slow" ); }); 
Javascript :: p5 colored line 
Javascript :: discord.js dm 
Javascript :: iterating over an array 
Javascript :: javascript make variable 
Javascript :: how to turn a multiple dimensional object into single array 
Javascript :: how to input struct into parameter in remix 
Javascript :: remove port number from url node js 
ADD CONTENT
Topic
Content
Source link
Name
2+4 =