私はオンライン製品サイトを作成しています。スクロール イベントをトリガーしています。開始時に 12 要素のみが表示されますが、8 番目の要素が一番上にスクロールされると、スクロール イベントは 1 回だけ実行されますが、下にスクロールするたびに実行されます。助けてください. ここに私のコードがあります:
var navigation_offset_top = $('.prods-list li:nth-child(4)').offset().top;
$(window).on("scroll",function(){
var scroll_top = $(window).scrollTop(); // current vertical position from the top
// if scrolled more than the navigation, change its position to fixed to stick to top, otherwise change it back to relative
if (scroll_top > sticky_navigation_offset_top)
{
console.log("Hi");
}
});