I have an issue using jquerys selectors when it comes to a page I am populating from a database.
The database populates a which will display 4 <li>
tags per row for x amount of rows.
I am trying to use addClass to give the first and last result on each row of the <ul>
a different class.
I have tried :first and :last but these obviously only add the classes needed to the very first result and the very last result. I need the added to the first and last of each row of 4.
My current code is:
$(document).ready(function(){
$("ul#display li.thumbs:first").addClass("start");
$("ul#display li.thumbs:last").addClass("end");
});
Example HTML
<ul>
<li><a href="/images/">image 1</a></li>
<li><a href="/images/">image 2</a></li>
<li><a href="/images/">image 3</a></li>
<li><a href="/images/">image 4</a></li>
<li><a href="/images/">image 5</a></li>
<li><a href="/images/">image 6</a></li>
<li><a href="/images/">image 7</a></li>
<li><a href="/images/">image 8</a></li>
<li><a href="/images/">image 9</a></li>
<li><a href="/images/">image 10</a></li>
<li><a href="/images/">image 11</a></li>
<li><a href="/images/">image 12</a></li>
</ul>