大小可变导航菜单演示
滚动鼠标后导航条栏目会变小
XML/HTML Code
- <div class="header large">
- <div class="inner">
- <h1><a href="http://www.freejs.net/"><img src="../../images/logo.png" alt="logo"></a></h1>
- <ul class="nav">
- <li><a class="cur" href="http://www.freejs.net/" title="freejs">freejs</a></li>
- <li><a href="http://www.aihym.com" title="爱薅羊毛">爱薅羊毛</a></li>
- </ul>
- </div>
- </div>
JavaScript Code
- <script>
- $(function(){
- $(window).on('scroll', function(){
- if($(window).scrollTop() > 100){
- $('.header').removeClass('large').addClass('small');
- } else {
- $('.header').removeClass('small').addClass('large');
- }
- });
- });
- </script>
原文地址:http://www.freejs.net/article_jquerywenzi_471.html