Answer the question
In order to leave comments, you need to log in
Change style of arbitrary list items?
Hello, I need help in resolving my situation. There is a list that is generated by the plugin, but you need to refer to an arbitrary element of this list.
list structure :
<ul id="test">
<li>1</li>
<li>2</li>
<li>3</li>
<li>4</li>
</ul>
Answer the question
In order to leave comments, you need to log in
css don't care if you have wordpress or not. Read this . If the question remains, then come back.
#UPD: Here's how you can:
<ul id="test">
<li>1</li>
<li>2</li>
<li>3</li>
<li>4</li>
</ul>
.red {
color: red;
}
const hours = new Date().getHours();
if (hours >= 9 && hours <= 15) {
document.querySelector('#test li:nth-child(3n)').classList.add('red')
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question