【问题标题】:Getting the src of the image active in a carousel of images在图像轮播中获取图像的 src
【发布时间】:2021-07-14 01:39:47
【问题描述】:

正如标题所说,我现在想在图像轮播中获取活动图像的 src,我的代码是这样的

$(document).ready(function () {
    $("#myCarousel1").on('slide.bs.carousel', function () {
        var ele = $('.carousel-inner .item .active').val('.carousel - inner.item.active').toString();
        var totalItems = $('.item').text().length;
        //for (var i = 0; i < totalItems; i++) {
        //    var valeur = $('.item').index(i);
        //    console.log('balkchi n: ' + valeur
        //    );
        //}
        console.log('target: ' + totalItems);
        alert(totalItems);

        $.ajax({
            url: '@Url.Action("Description", "Experience")',
            data: { 'Activite': totalItems },
            type: "post",
            success: function (data) {
                $("#loadpartial").html(data);
            }
        });
    });
});

【问题讨论】:

    标签: javascript asp.net ajax


    【解决方案1】:

    在你的函数中试试这个:

    var imageSrc = $('.active').find('img').attr('src');
    console.log(imageSrc);
    

    【讨论】:

    • 谢谢你,我得到了img的src路径
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-06-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多