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.