jcarousel打开带有加载而不是单击的项目

时间:2012-05-08 17:37:38

标签: jquery jcarousel

我只是希望这个jcarousel在加载“li img”而不是点击唱片页面时打开链接。 我是一名学习jQuery的设计师。请跟我一起轻松一下。那是我的第一个问题。 :)

$(function () {
    /**
     * build the carousel for the Albums
     */
    $('#mp_albums').jcarousel({
        scroll: 1,
        wrap: 'both',
    }).children('li').bind('click', function () {
        //when clicking on an Album, display its info, and hide the current one
        var $this = $(this);
        $('#mp_content_wrapper').find('.mp_content:visible').hide();

        $('#mp_content_wrapper').find('.mp_content:nth-child(' + parseInt($this.index() + 1) + ')').fadeIn(1000);

    });

});

提前致谢。

1 个答案:

答案 0 :(得分:0)

我使用this jCarousel page作为查找相应回调的参考。看起来你想要itemVisibleInCallback。这应该让你开始。如果您有任何问题/问题,请告诉我们,我们可以编辑我的答案。

$(function () {
    /**
     * build the carousel for the Albums
     */
    $('#mp_albums').jcarousel({
        scroll: 1,
        wrap: 'both',
        itemVisibleInCallback: {
            onAfterAnimation: openInfo
        }
    });

    function openInfo(carousel, item, idx, state){
        //when clicking on an Album, display its info, and hide the current one
        var $this = $(item);
        $('#mp_content_wrapper').find('.mp_content:visible').hide();

        $('#mp_content_wrapper').find('.mp_content:nth-child(' +    parseInt($this.index() + 1) + ')').fadeIn(1000);
    }
});
相关问题