hi everyone.
i have a data.json file where i have stored many fields. i want to display only 10 of them in a div with id news.this loop shows all of them. any help how can i realize it ?

$(function() {
$.getJSON('data.json', function(data) {
$.each(data, function(i, f) {
var title = "<p>"+f.title+"</p>"
$("#news").append(title);
});
});
});

you need an escape to exit $.each() loop.

$.each(data, function(i,f){
if(i==9){
    return false;
}
});
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.