大佬教程收集整理的这篇文章主要介绍了jquery – 单击菜单链接从一个div移动到另一个div,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
那么大家,如果你知道任何jquery插件可以帮助我在这种情况下,那么请让我知道,如果你也向我展示一个例子会更好.
.Home-section { height: 500px; BACkground: deepskyblue; } .About-section { height: 300px; BACkground: deeppink; }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.2/jquery.min.js"></script> <a href="#">Home</a> <a href="#">About</a> <div class="Home-section"> <h1> Hello </h1> </div> <div class="About-section"> <h1>Bye</h1> </div>
// handle links with @href started with '#' only $(document).on('click','a[href^="#"]',function(E) { // target element id var id = $(this).attr('href'); // target element var $id = $(id); if ($id.length === 0) { return; } // prevent standard hash navigation (avoid blinking in IE) e.preventDefault(); // top position relative to the document var pos = $(id).offset().top - 10; // animated top scrolling $('body,html').animate({scrollTop: pos}); });
.Home-section { height:500px; BACkground: deepskyblue; } .About-section { height:300px; BACkground:deeppink; }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <a href="#home">Home</a> <a href="#about">About</a> <div class="Home-section" id="home"><h1> Hello </h1> </div> <div class="About-section" id="about"><h1>Bye</h1> </div>
以上是大佬教程为你收集整理的jquery – 单击菜单链接从一个div移动到另一个div全部内容,希望文章能够帮你解决jquery – 单击菜单链接从一个div移动到另一个div所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。