单击引导程序而不是转盘没有活动src

时间:2016-04-27 21:45:52

标签: javascript jquery html twitter-bootstrap-3 carousel

我正在尝试获取活动轮播元素的src。它选择最初活动的src,然后永远不会更新后续点击。 我的代码基于this问题。

我已经阅读过关于运行时的绑定但是没有一个建议的解决方案有效(例如在.click之后添加.update)。

这是我的剧本:

   $('#myCarousel').on('click',function(event){
        var currslide = $('.active').find('img').attr('src');
        alert(currslide);         
   });

这是我的旋转木马HTML:

<!-- Carousel ================================================== -->
<div id="myCarousel" class="carousel slide" data-interval="false">
    <div id="theme-selecting" class="carousel-inner">
        <div class="item active">
            <div class="row">
                <div class="col-xs-6 col-sm-3 col-md-3 col-lg-3">
                    <input type="radio" name="rGroup" value="1" id="r1" checked="checked" />
                    <label class="whatever text-center" for="r1">
                        <img class="img-responsive" src="/images/logo.png" alt="">
                        <h3>
                            Holiday</h3>
                    </label>
                </div>
                <div class="col-xs-6 col-sm-3 col-md-3 col-lg-3">
                    <input type="radio" name="rGroup" value="2" id="r2" />
                    <label class="whatever text-center" for="r2">
                        <img class="img-responsive" src="/images/rain-drops.jpg" alt="">
                        <h3>
                            Holiday</h3>
                    </label>
                </div>
                <div class="col-xs-6 col-sm-3 col-md-3 col-lg-3">
                    <input type="radio" name="rGroup" value="3" id="r3" />
                    <label class="whatever text-center" for="r3">
                        <img class="img-responsive" src="/images/rain-drops.jpg" alt="">
                        <h3>
                            Holiday</h3>
                    </label>
                </div>
                <div class="col-xs-6 col-sm-3 col-md-3 col-lg-3">
                    <input type="radio" name="rGroup" value="4" id="r4" />
                    <label class="whatever text-center" for="r4">
                        <img class="img-responsive" src="/images/rain-drops.jpg" alt="">
                        <h3>
                            Holiday</h3>
                    </label>
                </div>
            </div>
        </div>
        <div class="item">
            <div class="row">
                <div class="col-xs-6 col-sm-3 col-md-3 col-lg-3">
                    <input type="radio" name="rGroup" value="5" id="r5" checked="checked" />
                    <label class="whatever text-center" for="r5">
                        <img class="img-responsive" src="/images/rain-drops.jpg" alt="">
                        <h3>
                            Holiday</h3>
                    </label>
                </div>
                <div class="col-xs-6 col-sm-3 col-md-3 col-lg-3">
                    <input type="radio" name="rGroup" value="6" id="r6" />
                    <label class="whatever text-center" for="r6">
                        <img class="img-responsive" src="/images/rain-drops.jpg" alt="">
                        <h3>
                            Holiday</h3>
                    </label>
                </div>
            </div>
        </div>
    </div>
    <a class="left carousel-control" href="#myCarousel" data-slide="prev"><i class="fa fa-chevron-left fa-2x">
    </i></a><a class="right carousel-control" href="#myCarousel" data-slide="next"><i
        class="fa fa-chevron-right fa-2x"></i></a>
        <!--<ol class="carousel-indicators">
                <li data-target="#myCarousel" data-slide-to="0" class="active">/li>
                <li data-target="#myCarousel" data-slide-to="1"></li>
                <li data-target="#myCarousel" data-slide-to="2"></li>
            </ol>   -->
</div>
<!-- End Carousel -->

0 个答案:

没有答案