I'm looking for a way to fill a <ul>
list up to 10 item. If the list doesn't have 10 in the HTML, I want the items to repeat themselves.
For example:
<ul id="carousel">
<li><a href="#">1</a></li>
<li><a href="#">2</a></li>
<li><a href="#">3</a></li>
<li><a href="#">4</a></li>
</ul>
I tried to do it myself, but it's not exactly working they way I want it to:
max_slides = 10;
slides_holder = $('#carousel');
all_slides = $('#carousel li');
number_of_slides = all_slides.length;
number_of_slides_to_add = max_slides - number_of_slides;
if( number_of_slides < max_slides)
{
slides_to_add = $('#carousel li:lt('+number_of_slides_to_add+')').clone();
slides_holder.append(slides_to_add);
}
// $('#carousel').initiateCarousel();
It should become this:
<ul id="carousel">
<li><a href="#">1</a></li>
<li><a href="#">2</a></li>
<li><a href="#">3</a></li>
<li><a href="#">4</a></li>
<li><a href="#">1</a></li>
<li><a href="#">2</a></li>
<li><a href="#">3</a></li>
<li><a href="#">4</a></li>
<li><a href="#">1</a></li>
<li><a href="#">2</a></li>
</ul>
The items should repeat themselves. It only works when there are 5 items or more... The reason is this: I'm using a special carousel plugin that should always have 10 items at all times. If it doesn't, it starts to act funky.
Thanks for any help.