0

この優れたチュートリアルに従って、私は非常に近くにいますが、彼はh2動的に作成されたものではなく、タグの内容を使用しています。代わりに画像のタイトルを使用したいと思います。このようなことがうまくいくと思いましたが、そうではありません。

$(document).ready(function () {
//Create an array of titles
var titles = $('#slideshow img.item').map(function() { 
    return $(this).prop('title'); 
});

    $('#pause').click(function() { $('#slideshow').cycle('pause'); return false });
    $('#play').click(function() { $('#slideshow').cycle('resume'); return false; });

    $('#slideshow').before('<ul id="nav-slide"></ul>').cycle({
        fx: 'fade', 
        speed: 'slow', 
        timeout: 6000, 
        pager: '#nav-slide',
        pagerAnchorBuilder: function (index) {  //Build the pager
            return '<li><a href="#">' + titles[index] + '</a></li>';
        },
        updateActivePagerLink: function(pager, currSlideIndex) {
            $(pager).find('li').removeClass('active').filter('li:eq('+currSlideIndex+')').addClass('active');
        }
    });

});

titleブロック/インライン要素ではなく、のコンテンツを取得する方法を知っている人はいますか?

4

1 に答える 1

1

titleは子ではなく、画像のプロパティです

var titles = $('#slideshow img.item').map(function() { 
    return $(this).prop('title'); 
});

デモ

于 2012-12-14T00:52:22.747 に答える