Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/78.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery 如何仅显示导航标签的相应div? var topRange=200,//从视口顶部测量到向下X像素 edgeMargin=20,//页眉上方的边距或页尾的边距 animationTime=1200,//以毫秒为单位的时间 contentTop=[]; $(文档).ready(函数(){ $('html,body').bind('scroll mousedown DOMMouseScroll mouseweelkeyup',函数(e){ 如果(e.which>0 | | e.type=='mousedown'| | e.type=='mouseweel'){ $('html,body').stop(); } }) //将内容设置为一组位置 $('#侧菜单')。查找('a')。每个(函数(){ push($($(this.attr('href')).offset().top); }) //“动画”菜单滚动到内容 $(“#侧菜单”)。查找('a')。单击(函数(){ var sel=这个, newTop=Math.min(contentTop[$(“#侧菜单a”).index($(this)),$(document.height()-$(window.height());//如果在文档底部,则获取内容顶部或顶部位置 $('html,body').stop().animate({'scrollTop':newTop},animationTime,function(){ window.location.hash=$(sel.attr('href'); }); 返回false; } ) $(窗口)。滚动(函数(){ var winTop=$(窗口).scrollTop(), bodyHt=$(文档).height(), vpHt=$(窗口).height()+边缘边缘;//视口高度+边距 $。每个(contentTop,函数(i,loc){ 如果((loc>winTop-edgeMargin&&(loc=bodyHt))){ $(“#侧菜单li”) .removeClass('选定') .eq(i).addClass(“选定”); } }) }) })_Jquery - Fatal编程技术网

Jquery 如何仅显示导航标签的相应div? var topRange=200,//从视口顶部测量到向下X像素 edgeMargin=20,//页眉上方的边距或页尾的边距 animationTime=1200,//以毫秒为单位的时间 contentTop=[]; $(文档).ready(函数(){ $('html,body').bind('scroll mousedown DOMMouseScroll mouseweelkeyup',函数(e){ 如果(e.which>0 | | e.type=='mousedown'| | e.type=='mouseweel'){ $('html,body').stop(); } }) //将内容设置为一组位置 $('#侧菜单')。查找('a')。每个(函数(){ push($($(this.attr('href')).offset().top); }) //“动画”菜单滚动到内容 $(“#侧菜单”)。查找('a')。单击(函数(){ var sel=这个, newTop=Math.min(contentTop[$(“#侧菜单a”).index($(this)),$(document.height()-$(window.height());//如果在文档底部,则获取内容顶部或顶部位置 $('html,body').stop().animate({'scrollTop':newTop},animationTime,function(){ window.location.hash=$(sel.attr('href'); }); 返回false; } ) $(窗口)。滚动(函数(){ var winTop=$(窗口).scrollTop(), bodyHt=$(文档).height(), vpHt=$(窗口).height()+边缘边缘;//视口高度+边距 $。每个(contentTop,函数(i,loc){ 如果((loc>winTop-edgeMargin&&(loc=bodyHt))){ $(“#侧菜单li”) .removeClass('选定') .eq(i).addClass(“选定”); } }) }) })

Jquery 如何仅显示导航标签的相应div? var topRange=200,//从视口顶部测量到向下X像素 edgeMargin=20,//页眉上方的边距或页尾的边距 animationTime=1200,//以毫秒为单位的时间 contentTop=[]; $(文档).ready(函数(){ $('html,body').bind('scroll mousedown DOMMouseScroll mouseweelkeyup',函数(e){ 如果(e.which>0 | | e.type=='mousedown'| | e.type=='mouseweel'){ $('html,body').stop(); } }) //将内容设置为一组位置 $('#侧菜单')。查找('a')。每个(函数(){ push($($(this.attr('href')).offset().top); }) //“动画”菜单滚动到内容 $(“#侧菜单”)。查找('a')。单击(函数(){ var sel=这个, newTop=Math.min(contentTop[$(“#侧菜单a”).index($(this)),$(document.height()-$(window.height());//如果在文档底部,则获取内容顶部或顶部位置 $('html,body').stop().animate({'scrollTop':newTop},animationTime,function(){ window.location.hash=$(sel.attr('href'); }); 返回false; } ) $(窗口)。滚动(函数(){ var winTop=$(窗口).scrollTop(), bodyHt=$(文档).height(), vpHt=$(窗口).height()+边缘边缘;//视口高度+边距 $。每个(contentTop,函数(i,loc){ 如果((loc>winTop-edgeMargin&&(loc=bodyHt))){ $(“#侧菜单li”) .removeClass('选定') .eq(i).addClass(“选定”); } }) }) }),jquery,Jquery,在这个提琴我想,只有相应的div将是可见的,而不是其他,当我们滚动,然后下一步将显示。所以它的工作原理就像我们在屏幕上滚动,下一个选项卡处于活动状态,相应的进入视口,并没有滚动,也并没有其他div的可见性 如何做到这一点,我必须将这一部分集成到一个完整的网页中,当用户一个接一个地滚动时,其中有1-10个功能,他可以看到这些功能。(单击即可正常工作,您需要在页面上应用它。)。我在我的页面上添加了这个。请看第四部分。你能解释一下什么不起作用吗?ohk会检查的。。非常感谢您的帮助:)如果您查看第四部分

在这个提琴我想,只有相应的div将是可见的,而不是其他,当我们滚动,然后下一步将显示。所以它的工作原理就像我们在屏幕上滚动,下一个选项卡处于活动状态,相应的进入视口,并没有滚动,也并没有其他div的可见性


如何做到这一点,我必须将这一部分集成到一个完整的网页中,当用户一个接一个地滚动时,其中有1-10个功能,他可以看到这些功能。

(单击即可正常工作,您需要在页面上应用它。)。我在我的页面上添加了这个。请看第四部分。你能解释一下什么不起作用吗?ohk会检查的。。非常感谢您的帮助:)如果您查看第四部分,您将看到侧栏未固定,并且其他div也可见。我只希望侧栏将固定,滚动div将根据选项卡不断更改。。rest我也在尝试更换容器
var topRange      = 200,  // measure from the top of the viewport to X pixels down
 edgeMargin    = 20,   // margin above the top or margin from the end of the page
 animationTime = 1200, // time in milliseconds
 contentTop = [];
 $(document).ready(function(){ 
 $('html,body').bind('scroll mousedown DOMMouseScroll mousewheel keyup',       function(e){
if ( e.which > 0 || e.type == 'mousedown' || e.type == 'mousewheel' ){
$('html,body').stop();
}
})

// Set up content an array of locations
$('#sidemenu').find('a').each(function(){
contentTop.push( $( $(this).attr('href') ).offset().top );
 })

// Animate menu scroll to content
$('#sidemenu').find('a').click(function(){
var sel = this,
   newTop = Math.min( contentTop[ $('#sidemenu a').index( $(this) ) ],   $(document).height() - $(window).height() ); // get content top or top position if at the document bottom
   $('html,body').stop().animate({ 'scrollTop' : newTop }, animationTime,    function(){
   window.location.hash = $(sel).attr('href');
    });
   return false;
    }  )


   $(window).scroll(function(){
   var winTop = $(window).scrollTop(),
   bodyHt = $(document).height(),
   vpHt = $(window).height() + edgeMargin;  // viewport height + margin
   $.each( contentTop, function(i,loc){
   if ( ( loc > winTop - edgeMargin && ( loc < winTop + topRange || (  winTop + vpHt ) >= bodyHt ) ) ){
   $('#sidemenu li')
  .removeClass('selected')
  .eq(i).addClass('selected');
   }
   })
   })

   })