我在用图片库建一些网站。
有一个正常的彩色盒启动脚本
$('.colorbox').colorbox({rel:'colorbox', opacity:'0.5',
current: '$s_photo[$lid]: {current}, $s_total[$lid]: {total}'});当我按下超链接覆盖img标签时,它就开始了。
但我也有一些img标签,没有超链接适合他们。这样,默认的power脚本就不能工作了。
但我有不同的部分起作用。
$('.colorbox').click(function() {
$(this).colorbox({rel:'colorbox', opacity:'0.5',
current: '$s_photo[$lid]: {current},
$s_total[$lid]: {total}', maxWidth: 960,
maxHeight: 640, scalePhotos: true,
href: $(this).attr('src')});
});在超链接和没有超链接的img标记中,这一项都可以激活img标记。现在问题来了。这样,就没有关于prev、下一个图像和总图像数量的箭头和信息。
有办法解决我的问题吗?
重复一遍,我的数据库中有两种类型的图片。
有没有办法将这两种类型组合在一个启动正常工作脚本下?
发布于 2011-08-16 22:28:53
你应该能够做到这一点:
$('.colorbox').colorbox({rel:'colorbox', opacity:'0.5',
current: '$s_photo[$lid]: {current}, $s_total[$lid]: {total}'});
$('img.colorbox').colorbox({href:function(){return $(this).src; }});你也可以这样做:
$('.colorbox').colorbox({rel:'colorbox', opacity:'0.5', current: '$s_photo[$lid]: {current}, $s_total[$lid]: {total}', href:
function(){
return this.src || this.href;
}});发布于 2011-08-15 14:00:36
..。这个怎么样:
1-通过类选择器将所有图像分组。
2-使用onLoad回调检查和设置未被超链接包装的图像的href值。
https://stackoverflow.com/questions/7065105
复制相似问题