0

我只希望这个 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);

    });

});

提前致谢。

4

1 回答 1

0

我使用这个 jCarousel 页面作为查找适当回调的参考。看起来你想要 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);
    }
});
于 2012-05-08T18:39:03.440 回答