I have some json array Data which have hundred of objects with data structure similar to following
var json = [{"id":"123","name":"user"},{"id":"124","name":"user2"},{"id":"125","name":"user4"}] I am creating dropdown using this data (ul and li) by using following function
var newhtml = $("<div/>"); json.forEach(function (e) { newhtml.append('<li>'+e.name+'</li>'); }); $('ul').append(newhtml.html()); This is working fine but the problem is if json data goes near thousand it slows down. I already googled and found few ways which includes:
- Avoid appending
litoulevery time. So I append only once afterforEachloop. It optimize things to not that much.
Now my question is How to create html using json data with optimized way ?