Skip to content
Advertisement

Substring all aria-label elements of an array

HTML

JavaScript

Here I have a JS script working to get the number of the active slide in result of a variable. to get it, I’ve substring info from “aria-label” (keeping only slide number before ” / 13″) of the active slide:

JavaScript

result // numactiveslide: “4”

**How to get the same for not 1 but 3 special slides (prev,active,next). I try to get the same, working for a new array of 3 actives slides (swiper-slide-prev, swiper-slide-active and swiper-slide-next).

This is the var of the selected slides:

JavaScript

Expected result is the 3 actives slides numbers: // numactiveslides = 3,4,5

How to get a code working by writing a loop or forEach or this kind of thing? This should be easy but I didn’t manage to repeat the substring for each element, to get at the end an array of :

JavaScript

Advertisement

Answer

ok, I’ve finally found the answer. It works fine.

JavaScript

//then do all the same for passives slides with covplayers.pause();

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement