【发布时间】:2018-09-16 20:57:54
【问题描述】:
如果这是基本的脚本,那么很抱歉,但是......
我有 2 个位置:固定 div,当特定 div 在屏幕上可见时,我想成为位置:相对。 (即,当出现 div 时滚动出屏幕)
'antxt' - 是默认的固定类,当屏幕上显示“trig”时,我想切换到“andtxtscroll”。我是根据一个没有运气的帖子在这里找到的。
$(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
我想让居中的徽标在下一个视图出现时向上滚动?
【问题讨论】:
标签: javascript jquery