webphp,
Вариант ... ссылки добавить не проблема
<!DOCTYPE HTML>
<html>
<head>
<title>Untitled</title>
<meta charset="utf-8">
<style type="text/css">
</style>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script>
$(function() {
function sortFunction(a, b) {
return a.name < b.name ? -1 : a.name > b.name ? 1 : 0
}
var arr = [
{"name": "Арбуз", "url": "url"},
{"name": "Ананас", "url": "url"},
{"name": "Background", "url": "url"},
{"name": "Border", "url": "url"},
{"name": "Add", "url": "url"},
{"name": "App", "url": "url"}
]
arr.sort(sortFunction);
var ul = $("<ul/>"),
li, sub, obj = {},
letter;
$.each(arr, function(indx, el) {
letter = el.name.charAt(0);
if (!obj[letter]) {
obj[letter] = true;
li = $("<li/>", {
"text": letter.toUpperCase()
});
li.appendTo(ul);
sub = $("<ul/>").appendTo(li)
}
$("<li/>", {
"text": el.name
}).appendTo(sub)
});
ul.appendTo("body")
});
</script>
</head>
<body>
</body>
</html>
|