Adding a Class
Hello. I'm looking for some JS help. I've seen a few other posts on this issue but decided to start a new thread to not cause confusion.
Here's my situation: I have tweaked the CPLibraryAll.css file to style my ordered list <li> tags with custom numbers. When learners select a RTL language, I need those styled numbers to reposition to the right. I have created a class for this. Where I am stuck right now is that I need to apply this class to those <li> elements.
I tried executing JS on my first slide when a user selects and presses the RTL language (in this case Arabic) button. Here is the code used:
var element = document.getElementById("swap");
element.classList.add("rtllist");
"swap" is the id I gave my <li> and "rtllist" is the class I have setup. I have this code being executed on slide 1 and the first instance where my targeted list items are is on slide 5. Is this part of the issue?
I could be going about this the wrong way, so I'm open for suggestions and any help I can get. Much appreciated!
And for good measure, here is the CSS I have tweaked:
ol {
counter-reset: my-awesome-counter;
list-style: none;
padding-left: 15px;
}
ol li {
margin: 0 0 0.5rem 0;
counter-increment: my-awesome-counter;
position: relative;
}
ol li::before {
content: counter(my-awesome-counter);
color: white;
font-size: 1rem;
font-family: Helvetica;
font-weight: bold;
position: absolute;
--size: 28px;
left: calc(-1 * var(--size) - -17px);
line-height: var(--size);
width: var(--size);
height: var(--size);
top: 0;
background: #B52625;
border-radius: 50%;
text-align: center;
}
ol li.rtllist::before {
left: calc(-1 * var(--size) - -300px);
}
