将标题添加到嵌套的Jquery Cycle [英] Add captions to nested Jquery Cycle

查看:86
本文介绍了将标题添加到嵌套的Jquery Cycle的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用jquery cycle插件由嵌套幻灯片组成的画廊.我希望基于alt的字幕显示在幻灯片中的每个图像上,但是我不知道我需要在脚本中的哪个位置激活它.如果有人可以帮忙,我将不胜感激.谢谢!

I've got a gallery constructed of nested slideshows using the jquery cycle plugin. I want captions based on the alt text to display on each image in the slideshow, but I don't know where in the script I would need to active this. If anyone could help, I'd be very appreciative. Thank you!

//stop subgal initially
            $('#hovergal .subgal').cycle({
                fx: 'fade',
                timeout: 10000,
                slideExpr: 'img'
            }).cycle('pause');

            //start subgal on click
            $('#hovergal').cycle({
                fx: 'scrollUp',
                speed: 300,
                timeout: 0,
                slideExpr: '>div.subgal',
                pager: 1,
                pagerAnchorBuilder: function(i) {
                    return $('aside.sgnav a:eq(' + i + ')');
                },
                after: function(curr,next,opts) {
                    var cmd = opts.currSlide == 1 ? 'resume' : 'pause';
                    $('div.subgal').cycle(cmd);
                }
            });
    } else {//else, if there's only one gallery to be shown

        $('#hovergal .subgal').cycle({
            fx: 'fade',
            timeout: 3000,
            slideExpr: 'img'
        }); 
    }

推荐答案

我猜每个人都像我一样陷入困境,因为我一直在努力寻找这个问题的答案已有两个星期,但没有运气.我已经放弃尝试在Jquery.Cycle的参数范围内解决它,而是改用列表而不是div来构建我的画廊,每个列表项都包含一个从alt标记中提取其内容的标题容器.完成后,我只需要将slideExpr更改为list,然后瞧瞧.

I'm guessing everyone is as stuck as I am, as I've been trying to find the answer for this question for two weeks without luck. I've given up trying to solve it within the parameters of Jquery.Cycle and have instead switched my galleries to be built from lists rather than divs, with the each list item containing a caption container that pulls its contents from the alt tag. That done, I just had to change slideExpr to list, and voila.

仍然不希望使用此方法,因为我不得不构造第二个Jquery语句,该语句在页面加载时检查每个标题容器,确定其是否包含任何内容,并在其为空时将其隐藏.但这是有效的,这时我真的很在乎.

This method is still not desired because I had to construct a second Jquery statement that checks each caption container on page load, determines if it has any content, and hides it if it's empty. But it works, and at this point that's really all I care about.

也许某天某人会提出这个问题的真正答案.同时,我把这留给所有可能遇到相同麻烦的人.

Maybe someone will come along with the real answer to this problem some day. In the meantime, I'm leaving this here for anyone who might run into the same jam.

这篇关于将标题添加到嵌套的Jquery Cycle的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆