Change ul style when arriving to div(scrolling)

后端 未结 6 1504
-上瘾入骨i
-上瘾入骨i 2020-12-18 17:24

I would like to change a ul style on scrolling and arrive to div using jQuery, explanation down.

CSS:

#menu {
    background-color:#ccc;
    position         


        
6条回答
  •  猫巷女王i
    2020-12-18 18:14

    Try something like this jsFiddle

    $(document).scroll(function () {
    var y = $(this).scrollTop();
    if (y > 275) {
        $(".menutext").addClass(
            "menutext2");
    } else {
        $(".menutext").removeClass(
            "menutext2");
    }
    

    });

    I have this set to add .menutext2 after you've scrolled down 275px, approximate top of div2, it shouldn't be hard to figure it out from here.

提交回复
热议问题