Answer the question
In order to leave comments, you need to log in
How to create a list of links in html from json?
Hello everyone
It is necessary to get a bulleted list from json, each element of which is a link.
Now the json file looks something like this:
{
"LinkList": [
{
"Name": "Fisrt",
"Link": "/first.html",
},
{
"Name": "Second",
"Link": "/second.html",
}
]
}
Answer the question
In order to leave comments, you need to log in
let's say your json is msg variable
then
msg = $.parseJSON(msg);
spisok = '<ul>';
for ( i=0; i<=msg.length(); i++ ) {
spisok = spisok+'<li><a href="'+msg[i]+'">Ссылка №'+i+'</a></li>';
}
spisok = spisok+'</ul>';
$('body').html(spisok);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question