0
I have the following code
function functionCLick(name) {
$.getJSON('livros.json', function(data){
$.each(data, function(i, item){
if(item.name == name){
$("#conteudo").html("<p>"+item.chapters+"</p>");
}
});
});
}
follows a part of json
[
{
"abbrev": "hob",
"chapters": [
[
"exemplo1.",
"exemplo2.",
"exemplo3."
],
[
"exemplo4.",
"exemplo5.",
"exemplo6."
]
],
"name": "hoobit"
},
]
my doubt is the following I wanted to know if you have how to format the output. My browser output is the following it inserts into html all the content that is in Chapters including it also shows the commas json end of line example: 1. ,exemple2. ,exemple3. ,exemple4. ,exemple5. ,exemple6. it returns me the commas that are at the end of each line of the Chapters json. I thought about removing all the commas with jquery but thinking, the text may have some comma that cannot be removed. And another doubt I can break Chapters
But you wanted each Cor to stay in one
<p>
different ?– Isac
You can use regex to remove the commas at the end of the text and leave any other comma that may come in it.
– LeAndrade