Home >Web Front-end >JS Tutorial >jQuery realizes the mouse wheel to dynamically change the style or effect_jquery

jQuery realizes the mouse wheel to dynamically change the style or effect_jquery

WBOY
WBOYOriginal
2016-05-16 16:22:051395browse

The code is as follows:

Copy code The code is as follows:

$(window).scroll(function() {
              var scrolls = $(this).scrollTop();
                $(".context_block").each(function(){ //Block-level element with class name "context_block"
              var height = $(this).height();
If($(this).position().top height-60> scrolls){
                                                                                                                                           var _index = $(".context_block").index($(this));
                                                                                                                                                                                                                                                                                through $($(".menu a")[_index]).addClass("hover_mobileLink");//Dynamically change the style of the a tag under the block-level element with class "menu" (add or delete a class)
                         return false;
                }
            });
        });

The core code is very simple, but the implementation effect is very good. I recommend it to my friends here.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn