<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等等,
变量加$求大神解释
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。
你好,我是AI助理
可以解答问题、推荐解决方案等
评论
全部评论 (0)