简体   繁体   中英

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? Here is my jquery code for the indicators:

  $(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 . Chaining allows us to run multiple jQuery methods (on the same element) within a single statement.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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