How to Show Hide tag Image When one of Owl Carousel item active?

  Kiến thức lập trình

I have an issue to show and hide image, it’s not working. How to if the owl-carousel active item that has id=”img-dark” will show img id=”dark” div and hide img id=”light”?

I have tried to try this

HTML

<div class="brand-name font-custom">
 <img src="img/logo.svg" class="logoheader" id="logo-light">
 <img src="img/logodark.svg" class="logoheader" id="logo-dark" style="display: none;">
</div>

JQuery

$(document).ready(function() {
        var owl = $('.owl-carousel');
        owl.on('changed.owl.carousel', function(event) {
          var visible = owl.find('.owl-item.active').find('#img-dark').is(':visible');
          if (visible) {
            $("#logo-dark").show();
            $("#logo-light").hide();
          } else {
            $("#logo-dark").hide();
            $("#logo-light").show();
          }
        });
      });

please help me to solve this problem

New contributor

Cynthia is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Theme wordpress giá rẻ Theme wordpress giá rẻ Thiết kế website

LEAVE A COMMENT