【发布时间】:2012-02-02 21:15:20
【问题描述】:
我正在尝试为朋友的夏季购物车系统进行新设计。系统通常有出现/消失的子类别菜单,但后来我下载了一个名为“灯箱”的 javascript 插件,它在当前窗口中显示图像,同时保留页面,而不是打开一个新窗口来显示图像。现在的问题是,这个“灯箱”插件有一个名为“prototype.js”的文件,导致子类别无法正常工作......
Prototype.js:http://www.mediafire.com/?sj3xzdw2gchmca0
使子菜单出现/消失的代码:
$(function () {
var stepOver = 20; // The number of pixels of the upper box that are going to cover its parent.
$("#DropdownCategories ul li").hover(
function () {
var firstUls = $(this).find('ul:first');
firstUls.show();
var positionLeft = $(this).position().left - stepOver + $(this).outerWidth();
var offsetLeft = $(this).offset().left - stepOver + $(this).outerWidth();
// Find the position that the box is going to end in.
var wouldEnd = offsetLeft + firstUls.outerWidth();
// If the box ends out of the body we move the box on the left side.
if (wouldEnd > $('body').innerWidth()) {
positionLeft = $(this).position().left - firstUls.outerWidth() + stepOver;
}
firstUls.css('position', 'absolute')
.css('top', $(this).position().top + 'px')
.css('left', positionLeft + 'px');
},
function () {
$(this).find('ul:first').hide();
}
);
});
实际网址:http://www.sladurko.com/product/277/bluza-kas-rakav.html
【问题讨论】:
-
您可以编辑代码以使其更具可读性吗?
-
尝试将其加载到 jsfiddle 上,然后以更整洁的格式发布。
-
这个问题一直被问到。让我去挖一个骗局。
标签: javascript jquery prototypejs lightbox