Home > Web Front-end > JS Tutorial > body text

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

WBOY
Release: 2016-05-16 16:22:05
Original
1326 people have browsed it

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.

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!