real new to scripting so apologies if this is basic but...
I have 2 position:fixed divs, which i want to become position:relative when a specific div is visible on screen. (ie, scroll out of screen when a div appears)
'antxt' - is the default fixed class, which i want to switch to 'andtxtscroll' when 'trig' is visible on screen. I have based this on a post found here with no luck.
$(window).scroll(function (event) {
var scroll = $(window).scrollTop();
$('andtxt').toggleClass('andtxtscroll',
scroll >= $('.trig').offset().top
);
});
//trigger the scroll
$(window).scroll();//ensure if you're in current position when page is refreshed
see https://anthonynoyce.design/
I want the centered logo to scroll up when the next view comes into view?
Change $('andtxt')
to $('.andtxt')
. Class selector should be preceded by .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.