I'm not 100% about how you want the workaround to work, but I'm going to hit him with this assumption:
, , , - LI, UL (lvl 0). LI UL (lvl1), - (lvl 1), LI (lvl 0).
, :
$('.clickit').click(function() {
var level = 0;
var $list = $('#treeList');
traverseList($list, level);
});
function traverseList($list, level) {
if ($list.length > 0) {
$list.children('li').each(function() {
$(this).prepend(level);
if ($(this).children('ul')) {
traverseList($(this).children('ul'), level + 1);
}
});
}
}
Fiddle : http://jsfiddle.net/xhh4wqv7/1/
. , , . , 1 1 , .
index(), , . , . , node , .closest('li') .
:
$("#MoveDown").click(function () {
var $tree = $('#treeList');
var $li = getLi($tree);
$tree.find('li').removeClass('parentStyle');
$li.addClass('parentStyle');
});
function getLi($tree) {
var $li = $tree.find('.parentStyle').last();
var $liList = $tree.find('li');
var idx = $liList.index($li);
if (idx < 0 || idx == $liList.length) { return $liList.first(); }
else { return $liList.eq(idx + 1); }
}
Fiddle: http://jsfiddle.net/xhh4wqv7/4/