How to add List items in jQuery?
I have the following code:
if (option.gene开发者_如何学运维ratePagination) {
elem.append('<ul class=' + option.paginationClass + '></ul>');
control.children().each(function () {
$('.' + option.paginationClass, elem).append('<li><a href="#' + number + '">' + (number + 1) + '</a></li>');
number++;
});
} else {
$('.' + option.paginationClass + ' li a', elem).each(function () {
$(this).attr('href', '#' + number);
number++;
});
}
$('.' + option.paginationClass + ' li:eq(' + start + ')', elem).addClass('current');
$('.' + option.paginationClass + ' li a', elem).click(function () {
if (option.play) {
pause();
}
I'd like to add <li class="prev"><a href="">Previous</a></li>
as the first list item, and <li class="next"><a href="">Next</a></li>
as the last list item.
So:
<ul>
<li class="prev"><a href="">Previous</a></li>
<li><a href="#' + number + '">' + (number + 1) + '</a></li>
<li class="next"><a href="">Next</a></li>
</ul>
How could i do this? Thank you.
$('ul').prepend('<li class="prev"><a href="">Previous</a></li>').append('<li class="next"><a href="">Next</a></li>');
精彩评论