Javascript jQuery自定义灯箱问题
我一直在编写自己的Lightbox脚本(以了解更多关于jQuery的信息) 我的标题代码如下(问题是每个图像上的标题都是相同的):Javascript jQuery自定义灯箱问题,javascript,jquery,Javascript,Jquery,我一直在编写自己的Lightbox脚本(以了解更多关于jQuery的信息) 我的标题代码如下(问题是每个图像上的标题都是相同的): 因此,我发现了问题所在(为邓干杯!),在代码的后面我有以下功能(我必须在删除标题代码中添加“链接”): 链接。每个(函数(索引){ var-link=$(这个); 链接。单击(功能(c){ c、 预防默认值(); 如果(隐藏滚动条==“1”){ $('body').css({'overflow':'hidden'}); } 打开(link.attr('href'))
因此,我发现了问题所在(为邓干杯!),在代码的后面我有以下功能(我必须在删除标题代码中添加“链接”):
链接。每个(函数(索引){
var-link=$(这个);
链接。单击(功能(c){
c、 预防默认值();
如果(隐藏滚动条==“1”){
$('body').css({'overflow':'hidden'});
}
打开(link.attr('href'));
links.filter('.selected').removeClass('selected');
link.addClass('selected');
var areterealts=$(“.thumb”,link).attr(“alt”);/“link”需要添加到此处
//警报(areThereAlts);
如果(areThereAlts!==“”){
container.append(“”+AretherAlts+“”)//标题
}
});
attr({'lb-position':index});
});
您正在做我很久以来一直想做的事情。。。
close.click(function(c) {
c.preventDefault();
if (hideScrollbars == "1") {
$('body').css({'overflow' : 'auto'});
}
overlay.add(container).fadeOut('normal');
$('#caption').animate({
opacity: 0.0
}, "5000", function() {
$('div').remove('#caption');
});
});
$(prev.add(next)).click(function(c) {
c.preventDefault();
$('div').remove('#caption')
areThereAlts = "";
var current = parseInt(links.filter('.selected').attr('lb-position'),10);
var to = $(this).is('.prev') ? links.eq(current - 1) : links.eq(current + 1);
if(!to.size()) {
to = $(this).is('.prev') ? links.eq(links.size() - 1) : links.eq(0);
}
if(to.size()) {
to.click();
}
});
links.each(function(index) {
var link = $(this);
link.click(function(c) {
c.preventDefault();
if (hideScrollbars == "1") {
$('body').css({'overflow' : 'hidden'});
}
open(link.attr('href'));
links.filter('.selected').removeClass('selected');
link.addClass('selected');
var areThereAlts = $(".thumb", link).attr("alt"); //"link" needed to be added here
//alert(areThereAlts);
if (areThereAlts !== "") {
container.append('<div id="caption" style="display: block; font-family: Verdana; background-color: white; padding: 4px 5px 10px 5px; top -10px; width: 100%; height: 25px; vertical-align: middle; -moz-border-radius-topleft: 10px; -moz-border-radius-topright: 10px; color: #3f3f3f;"><font color="#3f3f3f">'+areThereAlts+'</font></div>') //caption
}
});
link.attr({'lb-position': index});
});