Aquí está una extensión del prototipo jQuery ($ .fn) objeto proporcionar un nuevo método que puede ser encadenado a la función jQuery().
Necesitaba funcionalidad donde necesitaba agregar un elemento entre la lista que dividía. Eso se ha agregado como un parámetro opcional.
Un ejemplo está disponible en http://jsfiddle.net/roeburg/5F2hW/
El uso de la función es de esta manera:
$("ul").customSplitList(5);
La función se define de la siguiente manera:
// Function definition
(function ($) {
// Function is defined here ...
$.fn.customSplitList = function (indexToSplit, elementToAddInBetween) {
// Holds a reference to the element(list)
var that = this;
var subList, newList, listLength;
// Only continue if the element is a derivitive of a list
if ($(that) && ($(that).is("ul") || $(that).is("ol"))) {
// Additionally check if the length & the split index is valid
listLength = $(that).children().length;
if ($.isNumeric(indexToSplit) && indexToSplit > 0 && indexToSplit < listLength) {
// Based on list type, create a new empty list
newList = $($(that).clone(true)).empty();
while ((subList = this.find('li:gt(' + (indexToSplit - 1) + ')').remove()).length) {
newList.append(subList);
}
if (elementToAddInBetween && $(elementToAddInBetween)) {
that.after(newList);
newList.before(elementToAddInBetween);
} else {
that.after(newList);
}
}
}
};
})(jQuery);
Espero que esto ayude.
Hay una biblioteca que hace eso - https://github.com/yairEO/listBreaker – vsync