简体   繁体   English

导航栏轮播项目背景颜色

[英]Navbar carousel item background color

I have a navabar and carousel in the same section, what i want is when the carousel indicator becomes active it changes the background-color of the navbar and carousel item, any ideas on how to do that using jquery function? 我在同一部分中有一个导航栏和轮播,我想要的是当轮播指示器变为活动状态时,它会更改导航栏和轮播项目​​的背景颜色,有关如何使用jquery函数执行此操作的任何想法? Here is my jquery code for the indicators: 这是指标的我的jQuery代码:

  $(document).ready(function(ev){
        $('#carousel-example-generic').on('slide.bs.carousel', function (evt) {
        $('#carousel-example-generic .controls li.active').removeClass('active');    
        $('#carousel-example-generic .controls li:eq('+$(evt.relatedTarget).index()+')').addClass('active');        
            });

Try like this.With jQuery, you can chain together actions/methods . 像这样尝试。使用jQuery,您可以将actions/methods链接在一起。 Chaining allows us to run multiple jQuery methods (on the same element) within a single statement. 链接允许我们在单个语句中运行多个jQuery方法(在同一元素上)。

    $('#carousel-example-generic .controls li:eq('+$(evt.relatedTarget).index()+')').css('background-color','green').addClass('active');   //sets background-color green     

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM