开发者社区> 问答> 正文

没见过jQuery这种用法求解释

<script type="text/javascript">
    $(function(){
        /* function to make the thumbs menu scrollable */
        function buildThumbs($elem){
            var $wrapper        = $elem.next();
            var $menu       = $wrapper.find('.sc_menu');
            var inactiveMargin  = 150;
            /* move the scroll down to the
            beggining (move as much as the height of the menu) */
            $wrapper.scrollTop($menu.outerHeight());
            /* when moving the mouse up or down, the wrapper moves (scrolls) up or down */
            $wrapper.bind('mousemove',function(e){
                var wrapperHeight   = $wrapper.height();
                var menuHeight  = $menu.outerHeight() + 2 * inactiveMargin;
                var top     = (e.pageY - $wrapper.offset().top) * (menuHeight - wrapperHeight) / wrapperHeight - inactiveMargin;
                $wrapper.scrollTop(top+10);
            });
        }
        var stacktime;
        $('#menu li > a').bind('mouseover',function () {
            var $this = $(this);
            buildThumbs($this);
            var pos =   $this.next().find('a').size();
            var f   =   function(){
                if(pos==0) clearTimeout(stacktime);
                $this.next().find('a:nth-child('+pos+')').css('visibility','visible');
                --pos;
            };
            /* each thumb will appear with a delay */
            stacktime = setInterval(f , 50);
        });
        /* on mouseleave of the whole <li> the scrollable area is hidden */
        $('#menu li').bind('mouseleave',function () {
            var $this = $(this);
            clearTimeout(stacktime);
            $this.find('.sc_menu').css('visibility','hidden').find('a').css('visibility','hidden');
            $this.find('.sc_menu_wrapper').css('visibility','hidden');
        });
        /* when hovering a thumb, change its opacity */
        $('.sc_menu a').hover(
        function () {
            var $this = $(this);
            $this.find('img')
            .stop()
            .animate({'opacity':'1.0'},400);
        },
        function () {
            var $this = $(this);
            $this.find('img')
            .stop()
            .animate({'opacity':'0.3'},400);
        }
    );
    });
</script>

为什么是$wrapper啊 很多有加$的 我只知道$(function(){}),$.ajax等等,
变量加$求大神解释

展开
收起
a123456678 2016-07-12 14:19:47 1735 0
1 条回答
写回答
取消 提交回答
  • 带$表示是jquery对象,可以直接使用这个对象变量使用jquery方法

    2019-07-17 19:54:53
    赞同 展开评论 打赏
问答分类:
问答标签:
问答地址:
问答排行榜
最热
最新

相关电子书

更多
Python第五讲——关于爬虫如何做js逆向的思路 立即下载
现代Javascript高级教程 立即下载
JS零基础入门教程(上册) 立即下载