I am wondering if there is a way to select list items to add the css value to the list.
Itβs hard to explain, so let me show you an example:
<ul class="list"> <li></li> <li></li> <li></li> <li></li> .... </ul>
I would like to take a dynamically generated list like this, and
<ul class="list"> <li style="left:0px;"></li> <li style="left:10px;"></li> <li style="left:20px;"></li> <li style="left:30px;"></li> .... </ul>
I'm not sure if this is best done using jQuery, or if there is a CSS selector type that I don't know about, it can do it.
If I were using jQuery, I think it might look something like this:
$('.list > li:nth-child(2)').css('left', '+=10px').next
But I'm not sure how to clear the rest of the list and keep adding 10px every time. I play the idea of ββusing ".next" and ".prev", but I'm not sure how to do this.
Thanks for your patience, I'm new to jQuery.
source share