R
R
Ruslan Dasaev2018-12-13 17:05:37
css
Ruslan Dasaev, 2018-12-13 17:05:37

How can I add a class to a specific slide when the page has finished loading?

Hello. There is a code that adds a certain class to the 3rd active slide when the slide state changes:

on('changed.owl.carousel', function(property) {
    var item = $('.owl-item');
    var current = property.item.index;
  var last = current+2;
  $('.owl-item .carousel-works__item').removeClass('current');
  $(property.target).find(".owl-item").eq(last).find('.carousel-works__item').addClass('current');
  });

That is, to make the slide stand out, you need to scroll through it, but how to make it stand out immediately after the page loads? I tried something like this with initialize.owl.carousel/initialized.owl.carousel :
$('.carousel-works').owlCarousel().on('initialize.owl.carousel', function() {
    var item = $('.owl-item');
    var current = property.item.index;
  var last = current+2;
  $(property.target).find(".owl-item").eq(last).find('.carousel-works__item').addClass('current');
  }).on('changed.owl.carousel', function(property) {
    var item = $('.owl-item');
    var current = property.item.index;
  var last = current+2;
  $('.owl-item .carousel-works__item').removeClass('current');
  $(property.target).find(".owl-item").eq(last).find('.carousel-works__item').addClass('current');
  });

Or is it possible to prescribe a class in the html of the 3rd slide, but if you delete it in the future in the admin panel, then everything will fly off?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question