- (jsFiddle). , jsonObjects - .
function populateTypes() {
var availableTypes = [];
for(var i = 0; i < jsonObjects.length; i++) {
if(availableTypes.indexOf(jsonObjects[i].type) < 0) {
availableTypes.push(jsonObjects[i].type);
$('<li><a href="#">' + jsonObjects[i].type + '</a></li>')
.data('type', jsonObjects[i].type)
.on('click', function(){ $('#currenttype').text($(this).data('type')); })
.appendTo('#changetotypes');
}
}
}
, < li/ > , currenttype.
, currenttype, < li/ > , , , , ( . ) < a/ > ( $('a', $(this)). text()).